diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2016-04-01 21:40:14 +0200 |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2016-04-01 21:40:14 +0200 |
commit | 89d3f53aacc78a196bc2f57643a19b15974aa630 (patch) | |
tree | e70e35a9c1e76a96ab1f352ed99013a975c12ae0 /Lib/asyncio/tasks.py | |
parent | dcfebb32e277a68b9c6582e6a0484e6dc24e9b66 (diff) | |
parent | 2ba8ece5beb64126c719a837431cee3de890e451 (diff) | |
download | cpython-89d3f53aacc78a196bc2f57643a19b15974aa630.tar.gz cpython-89d3f53aacc78a196bc2f57643a19b15974aa630.zip |
Merge 3.5 (asyncio)
Diffstat (limited to 'Lib/asyncio/tasks.py')
-rw-r--r-- | Lib/asyncio/tasks.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/Lib/asyncio/tasks.py b/Lib/asyncio/tasks.py index c37aa4195db..cab4998ee44 100644 --- a/Lib/asyncio/tasks.py +++ b/Lib/asyncio/tasks.py @@ -401,7 +401,7 @@ def wait_for(fut, timeout, *, loop=None): @coroutine def _wait(fs, timeout, return_when, loop): - """Internal helper for wait() and _wait_for(). + """Internal helper for wait() and wait_for(). The fs argument must be a collection of Futures. """ @@ -747,7 +747,7 @@ def timeout(timeout, *, loop=None): ... yield from coro() - timeout: timeout value in seconds + timeout: timeout value in seconds or None to disable timeout logic loop: asyncio compatible event loop """ if loop is None: @@ -768,8 +768,9 @@ class _Timeout: if self._task is None: raise RuntimeError('Timeout context manager should be used ' 'inside a task') - self._cancel_handler = self._loop.call_later( - self._timeout, self._cancel_task) + if self._timeout is not None: + self._cancel_handler = self._loop.call_later( + self._timeout, self._cancel_task) return self def __exit__(self, exc_type, exc_val, exc_tb): @@ -777,8 +778,9 @@ class _Timeout: self._cancel_handler = None self._task = None raise futures.TimeoutError - self._cancel_handler.cancel() - self._cancel_handler = None + if self._timeout is not None: + self._cancel_handler.cancel() + self._cancel_handler = None self._task = None def _cancel_task(self): |