Skip to content

Commit

Permalink
Always cast frames to memoryviews
Browse files Browse the repository at this point in the history
  • Loading branch information
jakirkham committed Jul 28, 2021
1 parent bf83431 commit 1b974d0
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions distributed/comm/tcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,11 @@ async def write(self, msg, serializers=None, on_error="message"):
if stream._write_buffer is None:
raise StreamClosedError()

if isinstance(each_frame, memoryview):
# Make sure that `len(data) == data.nbytes`
# See <https://github.com/tornadoweb/tornado/pull/2996>
each_frame = each_frame.cast("B")
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")

stream._write_buffer.append(each_frame)
stream._total_write_index += each_frame_nbytes
Expand Down

0 comments on commit 1b974d0

Please sign in to comment.