MCPcopy Index your code
hub / github.com/python/cpython / _recv_bytes

Method _recv_bytes

Lib/multiprocessing/connection.py:317–357  ·  view source on GitHub ↗
(self, maxsize=None)

Source from the content-addressed store, hash-verified

315 assert nwritten == len(buf)
316
317 def _recv_bytes(self, maxsize=None):
318 if self._got_empty_message:
319 self._got_empty_message = False
320 return io.BytesIO()
321 else:
322 bsize = 128 if maxsize is None else min(maxsize, 128)
323 try:
324 ov, err = _winapi.ReadFile(self._handle, bsize,
325 overlapped=True)
326
327 sentinel = object()
328 return_value = sentinel
329 try:
330 try:
331 if err == _winapi.ERROR_IO_PENDING:
332 waitres = _winapi.WaitForMultipleObjects(
333 [ov.event], False, INFINITE)
334 assert waitres == WAIT_OBJECT_0
335 except:
336 ov.cancel()
337 raise
338 finally:
339 nread, err = ov.GetOverlappedResult(True)
340 if err == 0:
341 f = io.BytesIO()
342 f.write(ov.getbuffer())
343 return_value = f
344 elif err == _winapi.ERROR_MORE_DATA:
345 return_value = self._get_more_data(ov, maxsize)
346 except:
347 if return_value is sentinel:
348 raise
349
350 if return_value is not sentinel:
351 return return_value
352 except OSError as e:
353 if e.winerror == _winapi.ERROR_BROKEN_PIPE:
354 raise EOFError
355 else:
356 raise
357 raise RuntimeError("shouldn't get here; expected KeyboardInterrupt")
358
359 def _poll(self, timeout):
360 if (self._got_empty_message or

Callers

nothing calls this directly

Calls 4

writeMethod · 0.95
_get_more_dataMethod · 0.95
cancelMethod · 0.45
getbufferMethod · 0.45

Tested by

no test coverage detected