Skip to content

Commit 2620cfd

Browse files
authored
Improving the performance of the read_message by not splitting the da… (#90)
* Improving the performance of the read_message by not splitting the data into 1024 chunks and stitching them together as you go, instead receiving the entire message all at once. * Updating the changelog
1 parent 26f3285 commit 2620cfd

File tree

2 files changed

+3
-10
lines changed

2 files changed

+3
-10
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ Add linter, unit tests, and test coverage reporting
6060

6161
### Changed
6262

63+
Improving the performance of the read_message in client.py, This is done by receiving the entire message all at once instead of reading 1024 byte chunks and stitching them together as you go.
64+
6365
### Deprecated
6466

6567
### Removed

src/ros_tcp_endpoint/client.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,7 @@ def read_message(conn):
9797
destination = ClientThread.read_string(conn)
9898
full_message_size = ClientThread.read_int32(conn)
9999

100-
while len(data) < full_message_size:
101-
# Only grabs max of 1024 bytes TODO: change to TCPServer's buffer_size
102-
grab = 1024 if full_message_size - len(data) > 1024 else full_message_size - len(data)
103-
packet = ClientThread.recvall(conn, grab)
104-
105-
if not packet:
106-
rospy.logerr("No packets...")
107-
break
108-
109-
data += packet
100+
data = ClientThread.recvall(conn, full_message_size)
110101

111102
if full_message_size > 0 and not data:
112103
rospy.logerr("No data for a message size of {}, breaking!".format(full_message_size))

0 commit comments

Comments
 (0)