MCPcopy Index your code
hub / github.com/RustPython/RustPython / _wait_for_data

Method _wait_for_data

Lib/asyncio/streams.py:515–541  ·  view source on GitHub ↗

Wait until feed_data() or feed_eof() is called. If stream was paused, automatically resume it.

(self, func_name)

Source from the content-addressed store, hash-verified

513 self._paused = True
514
515 async def _wait_for_data(self, func_name):
516 """Wait until feed_data() or feed_eof() is called.
517
518 If stream was paused, automatically resume it.
519 """
520 # StreamReader uses a future to link the protocol feed_data() method
521 # to a read coroutine. Running two read coroutines at the same time
522 # would have an unexpected behaviour. It would not possible to know
523 # which coroutine would get the next data.
524 if self._waiter is not None:
525 raise RuntimeError(
526 f'{func_name}() called while another coroutine is '
527 f'already waiting for incoming data')
528
529 assert not self._eof, '_wait_for_data after EOF'
530
531 # Waiting for data while paused will make deadlock, so prevent it.
532 # This is essential for readexactly(n) for case when n > self._limit.
533 if self._paused:
534 self._paused = False
535 self._transport.resume_reading()
536
537 self._waiter = self._loop.create_future()
538 try:
539 await self._waiter
540 finally:
541 self._waiter = None
542
543 async def readline(self):
544 """Read chunk of data from the stream until newline (b'\n') is found.

Callers 3

readuntilMethod · 0.95
readMethod · 0.95
readexactlyMethod · 0.95

Calls 2

resume_readingMethod · 0.45
create_futureMethod · 0.45

Tested by

no test coverage detected