8000 gh-129205: Update multiprocessing.forkserver to use os.readinto by cmaloney · Pull Request #129425 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-129205: Update multiprocessing.forkserver to use os.readinto #129425

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jan 30, 2025
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Rely on memoryview to track length, reduce temporaries
  • Loading branch information
cmaloney committed Jan 29, 2025
commit 3ef05bad4d8f2e1817177a1440b74d6ec7115092
8 changes: 4 additions & 4 deletions Lib/multiprocessing/forkserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,12 +383,12 @@ def _serve_one(child_r, fds, unused_fds, handlers):

def read_signed(fd):
data = bytearray(SIGNED_STRUCT.size)
bytes_read = 0
while bytes_read < SIGNED_STRUCT.size:
count = os.readinto(fd, memoryview(data)[bytes_read:])
unread = memoryview(data)
while unread:
count = os.readinto(fd, unread)
if count == 0:
raise EOFError('unexpected EOF')
bytes_read += count
unread = unread[count:]

return SIGNED_STRUCT.unpack(data)[0]

Expand Down
Loading
0