diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2015-07-25 00:40:40 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2015-07-25 00:40:40 (GMT) |
commit | eaf16abc68a09e2d976c37e34eb606f5b519f7ea (patch) | |
tree | d9440e1c79b158094e71c1238407ca5f7a7cdcfb /Lib/asyncio/streams.py | |
parent | 71080fc3518e2d3555f555340c3e93f3b108a5b8 (diff) | |
download | cpython-eaf16abc68a09e2d976c37e34eb606f5b519f7ea.zip cpython-eaf16abc68a09e2d976c37e34eb606f5b519f7ea.tar.gz cpython-eaf16abc68a09e2d976c37e34eb606f5b519f7ea.tar.bz2 |
asyncio: sync with github
* Fix ResourceWarning warnings in test_streams
* Return True from StreamReader.eof_received() to fix
http://bugs.python.org/issue24539 (but still needs a unittest).
Add StreamReader.__repr__() for easy debugging.
* remove unused imports
* Issue #234: Drop JoinableQueue on Python 3.5+
Diffstat (limited to 'Lib/asyncio/streams.py')
-rw-r--r-- | Lib/asyncio/streams.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/Lib/asyncio/streams.py b/Lib/asyncio/streams.py index 6cd60c4..6484c43 100644 --- a/Lib/asyncio/streams.py +++ b/Lib/asyncio/streams.py @@ -6,7 +6,6 @@ __all__ = ['StreamReader', 'StreamWriter', 'StreamReaderProtocol', ] import socket -import sys if hasattr(socket, 'AF_UNIX'): __all__.extend(['open_unix_connection', 'start_unix_server']) @@ -240,6 +239,7 @@ class StreamReaderProtocol(FlowControlMixin, protocols.Protocol): def eof_received(self): self._stream_reader.feed_eof() + return True class StreamWriter: @@ -321,6 +321,24 @@ class StreamReader: self._transport = None self._paused = False + def __repr__(self): + info = ['StreamReader'] + if self._buffer: + info.append('%d bytes' % len(info)) + if self._eof: + info.append('eof') + if self._limit != _DEFAULT_LIMIT: + info.append('l=%d' % self._limit) + if self._waiter: + info.append('w=%r' % self._waiter) + if self._exception: + info.append('e=%r' % self._exception) + if self._transport: + info.append('t=%r' % self._transport) + if self._paused: + info.append('paused') + return '<%s>' % ' '.join(info) + def exception(self): return self._exception |