diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2015-01-09 20:32:05 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2015-01-09 20:32:05 (GMT) |
commit | 70db9e428aa476682ca80369d09a968b35729845 (patch) | |
tree | 8ae8f3ec699f537280445f089804feac93bd35ae /Lib/asyncio/streams.py | |
parent | 7eb10311be26e8f353530ed79476d4c859243401 (diff) | |
download | cpython-70db9e428aa476682ca80369d09a968b35729845.zip cpython-70db9e428aa476682ca80369d09a968b35729845.tar.gz cpython-70db9e428aa476682ca80369d09a968b35729845.tar.bz2 |
asyncio: sync with Tulip
* Tulip issue 184: FlowControlMixin constructor now get the event loop if the
loop parameter is not set. Add unit tests to ensure that constructor of
StreamReader and StreamReaderProtocol classes get the event loop.
* Remove outdated TODO/XXX
Diffstat (limited to 'Lib/asyncio/streams.py')
-rw-r--r-- | Lib/asyncio/streams.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/Lib/asyncio/streams.py b/Lib/asyncio/streams.py index c77eb60..5a96b24 100644 --- a/Lib/asyncio/streams.py +++ b/Lib/asyncio/streams.py @@ -145,7 +145,10 @@ class FlowControlMixin(protocols.Protocol): """ def __init__(self, loop=None): - self._loop = loop # May be None; we may never need it. + if loop is None: + self._loop = events.get_event_loop() + else: + self._loop = loop self._paused = False self._drain_waiter = None self._connection_lost = False @@ -306,8 +309,9 @@ class StreamReader: # it also doubles as half the buffer limit. self._limit = limit if loop is None: - loop = events.get_event_loop() - self._loop = loop + self._loop = events.get_event_loop() + else: + self._loop = loop self._buffer = bytearray() self._eof = False # Whether we're done. self._waiter = None # A future. |