Commit e783f8de authored by Denis Bilenko's avatar Denis Bilenko

gevent.wait(): fix leak of a timer

- test__greenlet.py: add TestJoinAll0
parent e9ef480b
...@@ -618,7 +618,8 @@ def iwait(objects, timeout=None): ...@@ -618,7 +618,8 @@ def iwait(objects, timeout=None):
waiter = Waiter() waiter = Waiter()
switch = waiter.switch switch = waiter.switch
if timeout is not None: if timeout is not None:
get_hub().loop.timer(timeout, priority=-1, ref=False).start(waiter.switch, _NONE) timer = get_hub().loop.timer(timeout, priority=-1)
timer.start(waiter.switch, _NONE)
try: try:
count = len(objects) count = len(objects)
for obj in objects: for obj in objects:
...@@ -630,6 +631,8 @@ def iwait(objects, timeout=None): ...@@ -630,6 +631,8 @@ def iwait(objects, timeout=None):
return return
yield item yield item
finally: finally:
if timeout is not None:
timer.stop()
for obj in objects: for obj in objects:
obj.unlink(switch) obj.unlink(switch)
......
...@@ -433,6 +433,14 @@ class TestGet(greentest.GenericGetTestCase): ...@@ -433,6 +433,14 @@ class TestGet(greentest.GenericGetTestCase):
g.kill() g.kill()
class TestJoinAll0(greentest.GenericWaitTestCase):
g = gevent.Greenlet()
def wait(self, timeout):
gevent.joinall([self.g], timeout=timeout)
class TestJoinAll(greentest.GenericWaitTestCase): class TestJoinAll(greentest.GenericWaitTestCase):
def wait(self, timeout): def wait(self, timeout):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment