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

Method _loop_reading

Lib/asyncio/proactor_events.py:276–325  ·  view source on GitHub ↗
(self, fut=None)

Source from the content-addressed store, hash-verified

274 self._protocol.data_received(data)
275
276 def _loop_reading(self, fut=None):
277 length = -1
278 data = None
279 try:
280 if fut is not None:
281 assert self._read_fut is fut or (self._read_fut is None and
282 self._closing)
283 self._read_fut = None
284 if fut.done():
285 # deliver data later in "finally" clause
286 length = fut.result()
287 if length == 0:
288 # we got end-of-file so no need to reschedule a new read
289 return
290
291 # It's a new slice so make it immutable so protocols upstream don't have problems
292 data = bytes(memoryview(self._data)[:length])
293 else:
294 # the future will be replaced by next proactor.recv call
295 fut.cancel()
296
297 if self._closing:
298 # since close() has been called we ignore any read data
299 return
300
301 # bpo-33694: buffer_updated() has currently no fast path because of
302 # a data loss issue caused by overlapped WSASend() cancellation.
303
304 if not self._paused:
305 # reschedule a new read
306 self._read_fut = self._loop._proactor.recv_into(self._sock, self._data)
307 except ConnectionAbortedError as exc:
308 if not self._closing:
309 self._fatal_error(exc, 'Fatal read error on pipe transport')
310 elif self._loop.get_debug():
311 logger.debug("Read error on pipe transport while closing",
312 exc_info=True)
313 except ConnectionResetError as exc:
314 self._force_close(exc)
315 except OSError as exc:
316 self._fatal_error(exc, 'Fatal read error on pipe transport')
317 except exceptions.CancelledError:
318 if not self._closing:
319 raise
320 else:
321 if not self._paused:
322 self._read_fut.add_done_callback(self._loop_reading)
323 finally:
324 if length > -1:
325 self._data_received(data, length)
326
327
328class _ProactorBaseWritePipeTransport(_ProactorBasePipeTransport,

Calls 10

_data_receivedMethod · 0.95
doneMethod · 0.45
resultMethod · 0.45
cancelMethod · 0.45
recv_intoMethod · 0.45
_fatal_errorMethod · 0.45
get_debugMethod · 0.45
debugMethod · 0.45
_force_closeMethod · 0.45
add_done_callbackMethod · 0.45