Skip to content

Commit

Permalink
Drop now unneeded frame size check
Browse files Browse the repository at this point in the history
The `for`-loop already skips trivial size frames.
  • Loading branch information
jakirkham committed Jul 28, 2021
1 parent 445a38b commit 2c8939b
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions distributed/comm/tcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,25 +267,24 @@ async def write(self, msg, serializers=None, on_error="message"):
try:
# trick to enque all frames for writing beforehand
for each_frame_nbytes, each_frame in zip(frames_nbytes, frames):
if each_frame_nbytes:
each_frame = memoryview(each_frame)
each_frame = memoryview(each_frame)

# Make sure that `len(data) == data.nbytes`
# See <https://github.com/tornadoweb/tornado/pull/2996>
each_frame = each_frame.cast("B")
# Make sure that `len(data) == data.nbytes`
# See <https://github.com/tornadoweb/tornado/pull/2996>
each_frame = each_frame.cast("B")

# Workaround for OpenSSL 1.0.2 (can drop with OpenSSL 1.1.1)
for i, j in sliding_window(
2, range(0, each_frame_nbytes + C_INT_MAX, C_INT_MAX)
):
chunk = each_frame[i:j]
chunk_nbytes = chunk.nbytes
# Workaround for OpenSSL 1.0.2 (can drop with OpenSSL 1.1.1)
for i, j in sliding_window(
2, range(0, each_frame_nbytes + C_INT_MAX, C_INT_MAX)
):
chunk = each_frame[i:j]
chunk_nbytes = chunk.nbytes

if stream._write_buffer is None:
raise StreamClosedError()
if stream._write_buffer is None:
raise StreamClosedError()

stream._write_buffer.append(chunk)
stream._total_write_index += chunk_nbytes
stream._write_buffer.append(chunk)
stream._total_write_index += chunk_nbytes

# start writing frames
stream.write(b"")
Expand Down

0 comments on commit 2c8939b

Please sign in to comment.