Message239072
os.read_into() may be used by the following functions.
subprocess.Popen._execute_child():
# Wait for exec to fail or succeed; possibly raising an
# exception (limited in size)
errpipe_data = bytearray()
while True:
part = os.read(errpipe_read, 50000)
errpipe_data += part
if not part or len(errpipe_data) > 50000:
break
subprocess.Popen.communicate():
self._fileobj2output = {}
if self.stdout:
self._fileobj2output[self.stdout] = []
...
data = os.read(key.fd, 32768)
if not data:
...
self._fileobj2output[key.fileobj].append(data)
...
stdout = b''.join(...)
multiprocessing.Connection._recv():
def _recv(self, size, read=_read):
buf = io.BytesIO()
handle = self._handle
remaining = size
while remaining > 0:
chunk = read(handle, remaining)
n = len(chunk)
if n == 0:
if remaining == size:
raise EOFError
else:
raise OSError("got end of file during message")
buf.write(chunk)
remaining -= n
return buf
multiprocessing.read_unsigned():
def read_unsigned(fd):
data = b''
length = UNSIGNED_STRUCT.size
while len(data) < length:
s = os.read(fd, length - len(data))
if not s:
raise EOFError('unexpected EOF')
data += s
return UNSIGNED_STRUCT.unpack(data)[0]
The problem is that some functions still require to return a bytes, not a bytearray or something else. Converting a bytearray to a bytes still require a memory copy... |
|
Date |
User |
Action |
Args |
2015-03-23 21:26:50 | vstinner | set | recipients:
+ vstinner |
2015-03-23 21:26:50 | vstinner | set | messageid: <1427146010.29.0.499468124016.issue23754@psf.upfronthosting.co.za> |
2015-03-23 21:26:50 | vstinner | link | issue23754 messages |
2015-03-23 21:26:50 | vstinner | create | |
|