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

Class StreamReader

Lib/asyncio/streams.py:412–787  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

410 warnings.warn(f"unclosed {self!r}", ResourceWarning)
411
412class StreamReader:
413
414 _source_traceback = None
415
416 def __init__(self, limit=_DEFAULT_LIMIT, loop=None):
417 # The line length limit is a security feature;
418 # it also doubles as half the buffer limit.
419
420 if limit <= 0:
421 raise ValueError('Limit cannot be <= 0')
422
423 self._limit = limit
424 if loop is None:
425 self._loop = events.get_event_loop()
426 else:
427 self._loop = loop
428 self._buffer = bytearray()
429 self._eof = False # Whether we're done.
430 self._waiter = None # A future used by _wait_for_data()
431 self._exception = None
432 self._transport = None
433 self._paused = False
434 if self._loop.get_debug():
435 self._source_traceback = format_helpers.extract_stack(
436 sys._getframe(1))
437
438 def __repr__(self):
439 info = ['StreamReader']
440 if self._buffer:
441 info.append(f'{len(self._buffer)} bytes')
442 if self._eof:
443 info.append('eof')
444 if self._limit != _DEFAULT_LIMIT:
445 info.append(f'limit={self._limit}')
446 if self._waiter:
447 info.append(f'waiter={self._waiter!r}')
448 if self._exception:
449 info.append(f'exception={self._exception!r}')
450 if self._transport:
451 info.append(f'transport={self._transport!r}')
452 if self._paused:
453 info.append('paused')
454 return '<{}>'.format(' '.join(info))
455
456 def exception(self):
457 return self._exception
458
459 def set_exception(self, exc):
460 self._exception = exc
461
462 waiter = self._waiter
463 if waiter is not None:
464 self._waiter = None
465 if not waiter.cancelled():
466 waiter.set_exception(exc)
467
468 def _wakeup_waiter(self):
469 """Wakeup read*() functions waiting for data or EOF."""

Callers 3

open_connectionFunction · 0.70
factoryFunction · 0.70
open_unix_connectionFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected