From 3e48c62aef0cd35dee9c03f05b1386e5c59e125a Mon Sep 17 00:00:00 2001 From: Josep Cugat Date: Sat, 15 Apr 2017 12:37:44 +0200 Subject: [PATCH] Avoid creating TimerContext when there is no timeout This will allow to use aiohttp with ioloops that don't implement asyncio.Task.current_task, like Tornado's couroutine runner. More info: https://github.com/aio-libs/aiohttp/issues/1180 --- CHANGES.rst | 2 ++ CONTRIBUTORS.txt | 1 + aiohttp/helpers.py | 7 +++++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 576066795c2..98d97b97ff4 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -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) ------------------ diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index 88dd3a4e360..4f11452365c 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -84,6 +84,7 @@ Jesus Cea Jinkyu Yi Joel Watts Joongi Kim +Josep Cugat Julia Tsemusheva Julien Duponchelle Junjie Tao diff --git a/aiohttp/helpers.py b/aiohttp/helpers.py index fa743d4ab3e..ea6a9614b00 100644 --- a/aiohttp/helpers.py +++ b/aiohttp/helpers.py @@ -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):