From 6b61832b37728710d7a89bdf6bcac2349c2b8a07 Mon Sep 17 00:00:00 2001 From: Alex Key Date: Sat, 19 Mar 2016 17:39:53 +0300 Subject: [PATCH] Treat zero (0) timeout values as normal --- aiohttp/helpers.py | 4 ++-- tests/test_timeout.py | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/aiohttp/helpers.py b/aiohttp/helpers.py index 702e29aea64..a88771af797 100644 --- a/aiohttp/helpers.py +++ b/aiohttp/helpers.py @@ -477,7 +477,7 @@ def __enter__(self): if self._task is None: raise RuntimeError('Timeout context manager should be used ' 'inside a task') - if self._timeout: + if self._timeout is not None: self._cancel_handler = self._loop.call_later( self._timeout, self._cancel_task) return self @@ -487,7 +487,7 @@ def __exit__(self, exc_type, exc_val, exc_tb): self._cancel_handler = None self._task = None raise asyncio.TimeoutError - if self._timeout: + if self._timeout is not None: self._cancel_handler.cancel() self._cancel_handler = None self._task = None diff --git a/tests/test_timeout.py b/tests/test_timeout.py index 815ca5ec250..492da30cc22 100644 --- a/tests/test_timeout.py +++ b/tests/test_timeout.py @@ -50,15 +50,14 @@ def run(): loop.run_until_complete(run()) -@pytest.mark.parametrize("delay", [None, 0]) @pytest.mark.run_loop -def test_timeout_disable(loop, delay): +def test_timeout_disable(loop): @asyncio.coroutine def long_running_task(): yield from asyncio.sleep(0.1, loop=loop) return 'done' - with Timeout(delay, loop=loop): + with Timeout(None, loop=loop): resp = yield from long_running_task() assert resp == 'done'