Skip to content

Commit

Permalink
Treat zero (0) timeout values as normal
Browse files Browse the repository at this point in the history
  • Loading branch information
alexkey committed Mar 19, 2016
1 parent 06e0e52 commit 6b61832
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions aiohttp/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
5 changes: 2 additions & 3 deletions tests/test_timeout.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down

0 comments on commit 6b61832

Please sign in to comment.