Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
13 changes: 7 additions & 6 deletions Lib/multiprocessing/forkserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,13 +382,14 @@ def _serve_one(child_r, fds, unused_fds, handlers):
#

def read_signed(fd):
data = b''
length = SIGNED_STRUCT.size
while len(data) < length:
s = os.read(fd, length - len(data))
if not s:
data = bytearray(SIGNED_STRUCT.size)
unread = memoryview(data)
while unread:
count = os.readinto(fd, unread)
if count == 0:
raise EOFError('unexpected EOF')
data += s
unread = unread[count:]

return SIGNED_STRUCT.unpack(data)[0]

def write_signed(fd, n):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
:mod:`multiprocessing` forkserver now uses :func:`os.readinto` to read pid
Copy link
Member

Choose a reason for hiding this comment

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

I don't think that it's worth it to document this change to end users. I suggest to remove this NEWS entry.

of child processes saving memory allocations and copies.
Loading