Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d4b39a3

Browse files
committed
Extract session buffers as memoryviews
A bug in pyzmq forces us to have a workaround, which can be deleted when the pyzmq dependency is upgraded to fix pyzmq issue #646. Thanks to @minrk for helping work on the code and also for the bugfix in pyzmq.
1 parent 7c9205c commit d4b39a3

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

IPython/kernel/zmq/session.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -842,8 +842,11 @@ def deserialize(self, msg_list, content=True, copy=True):
842842
message['content'] = self.unpack(msg_list[4])
843843
else:
844844
message['content'] = msg_list[4]
845-
846-
message['buffers'] = msg_list[5:]
845+
buffers = [memoryview(b) for b in msg_list[5:]]
846+
if buffers and buffers[0].shape is None:
847+
# force copy to workaround pyzmq #646
848+
buffers = [memoryview(b.bytes) for b in msg_list[5:]]
849+
message['buffers'] = buffers
847850
# adapt to the current version
848851
return adapt(message)
849852

0 commit comments

Comments
 (0)