Skip to content

Commit

Permalink
Avoid creating TimerContext when there is no timeout
Browse files Browse the repository at this point in the history
This will allow to use aiohttp with ioloops that don't implement
asyncio.Task.current_task, like Tornado's couroutine runner.

More info: #1180
  • Loading branch information
jcugat committed Apr 15, 2017
1 parent cd8f4bf commit 3e48c62
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Changes

- Added `iter_chunks` to response.content object. #1805

- Avoid creating TimerContext when there is no timeout to allow compatibility with Tornado. #1817 #1180


2.0.7 (2017-04-12)
------------------
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ Jesus Cea
Jinkyu Yi
Joel Watts
Joongi Kim
Josep Cugat
Julia Tsemusheva
Julien Duponchelle
Junjie Tao
Expand Down
7 changes: 5 additions & 2 deletions aiohttp/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -641,8 +641,11 @@ def start(self):
return self._loop.call_at(at, self.__call__)

def timer(self):
timer = TimerContext(self._loop)
self.register(timer.timeout)
if self._timeout is not None and self._timeout > 0:
timer = TimerContext(self._loop)
self.register(timer.timeout)
else:
timer = TimerNoop()
return timer

def __call__(self):
Expand Down

0 comments on commit 3e48c62

Please sign in to comment.