Commit 1d80700d authored by Jason Madden's avatar Jason Madden

Merge pull request #608 from sublee/fix-607

Fix 607
parents cd634cd7 114753f0
......@@ -357,7 +357,7 @@ class Greenlet(greenlet):
self.__cancel_start()
if self.dead:
self.__handle_death_before_start()
self.__handle_death_before_start(exception)
else:
waiter = Waiter()
self.parent.loop.run_callback(_kill, self, exception, waiter)
......
# A greenlet that's killed with an exception should fail.
import greentest
import gevent
class ExpectedError(greentest.ExpectedException):
pass
def f():
gevent.sleep(999)
class TestKillWithException(greentest.TestCase):
def test_kill_without_exception(self):
g = gevent.spawn(f)
g.kill()
assert g.successful()
assert isinstance(g.get(), gevent.GreenletExit)
def test_kill_with_exception(self):
# issue-607 pointed this case.
g = gevent.spawn(f)
g.kill(ExpectedError)
assert not g.successful()
self.assertRaises(ExpectedError, g.get)
assert g.value is None
assert isinstance(g.exception, ExpectedError)
def test_kill_with_exception_after_started(self):
g = gevent.spawn(f)
g.join(0)
g.kill(ExpectedError)
assert not g.successful()
self.assertRaises(ExpectedError, g.get)
assert g.value is None
assert isinstance(g.exception, ExpectedError)
if __name__ == '__main__':
greentest.main()
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