Skip to content
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Lib/multiprocessing/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ def _recv(self, size, read=_read):
def _send_bytes(self, buf):
n = len(buf)
# For wire compatibility with 3.2 and lower
header = struct.pack("!i", n)
header = struct.pack("!Q", n)
if n > 16384:
# The payload is large so Nagle's algorithm won't be triggered
# and we'd better avoid the cost of concatenation.
Expand All @@ -404,8 +404,8 @@ def _send_bytes(self, buf):
self._send(header + buf)

def _recv_bytes(self, maxsize=None):
buf = self._recv(4)
size, = struct.unpack("!i", buf.getvalue())
buf = self._recv(8)
size, = struct.unpack("!Q", buf.getvalue())
if maxsize is not None and size > maxsize:
return None
return self._recv(size)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
On Linux, fix multiprocessing.Connection for very large read: fix multiprocessing Connection._recv_bytes and Connection._send_bytes for read larger than INT_MAX (usually 2^31-1).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not only on Linux but on any Unix-like / POSIX system.
Suggestion:

Allow sending more than 2 GB at once on a multiprocessing connection on non-Windows systems.