mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
gh-129205: Update multiprocessing.forkserver to use os.readinto() (#129425)
This commit is contained in:
parent
510fefdc62
commit
10ee2d9d3b
1 changed files with 7 additions and 6 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue