Skip to content

Commit

Permalink
fix memory leak in time service #1656
Browse files Browse the repository at this point in the history
  • Loading branch information
fafhrd91 committed Feb 20, 2017
1 parent 112f1e3 commit 994b502
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions aiohttp/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -719,9 +719,10 @@ def timeout(self, timeout):
raise RuntimeError

if timeout:
ctx = _TimeServiceTimeoutContext(self._loop)
when = self._loop_time + timeout
ctx = _TimeServiceTimeoutContext(when, self._loop)
heapq.heappush(self._scheduled, ctx)
timer = TimerHandle(when, ctx.cancel, (), self._loop)
heapq.heappush(self._scheduled, timer)
else:
ctx = _TimeServiceTimeoutNoop()

Expand All @@ -737,14 +738,13 @@ def __exit__(self, exc_type, exc_val, exc_tb):
return False


class _TimeServiceTimeoutContext(TimerHandle):
class _TimeServiceTimeoutContext:
""" Low resolution timeout context manager """

def __init__(self, when, loop):
def __init__(self, loop):
assert loop is not None, "loop is not set"

super().__init__(when, self.cancel, (), loop)

self._loop = loop
self._tasks = []
self._cancelled = False

Expand Down

0 comments on commit 994b502

Please sign in to comment.