Commit 73c55de3 authored by Denis Bilenko's avatar Denis Bilenko

test__greenletset.py: avoid leaking greenlets out of the test case

parent 38360e26
...@@ -6,6 +6,10 @@ from gevent import pool ...@@ -6,6 +6,10 @@ from gevent import pool
DELAY = 0.1 DELAY = 0.1
class SpecialError(Exception):
pass
class Undead(object): class Undead(object):
def __init__(self): def __init__(self):
...@@ -15,6 +19,8 @@ class Undead(object): ...@@ -15,6 +19,8 @@ class Undead(object):
while True: while True:
try: try:
gevent.sleep(1) gevent.sleep(1)
except SpecialError:
break
except: except:
self.shot_count += 1 self.shot_count += 1
...@@ -106,6 +112,9 @@ class Test(greentest.TestCase): ...@@ -106,6 +112,9 @@ class Test(greentest.TestCase):
assert len(s) == 2, s assert len(s) == 2, s
check(1, 1) check(1, 1)
p1.kill(SpecialError)
p2.kill(SpecialError)
def test_killall_subclass(self): def test_killall_subclass(self):
p1 = GreenletSubclass.spawn(lambda: 1 / 0) p1 = GreenletSubclass.spawn(lambda: 1 / 0)
p2 = GreenletSubclass.spawn(lambda: gevent.sleep(10)) p2 = GreenletSubclass.spawn(lambda: gevent.sleep(10))
......
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