From: A. Jesse Jiryu Davis Date: Wed, 18 Feb 2015 13:56:52 +0000 (-0500) Subject: Fix multiple calls to Event.clear. X-Git-Tag: v4.2.0b1~103^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1c3d22fcf5305ebe506c4ac1e5ab760b7ddf4c04;p=thirdparty%2Ftornado.git Fix multiple calls to Event.clear. --- diff --git a/tornado/locks.py b/tornado/locks.py index 62d962b81..73cc9e2b8 100644 --- a/tornado/locks.py +++ b/tornado/locks.py @@ -110,7 +110,8 @@ class Event(object): Calls to `.wait` will block until `.set` is called. """ - self._future = Future() + if self._future.done(): + self._future = Future() def wait(self, timeout=None): """Block until the internal flag is true. diff --git a/tornado/test/locks_test.py b/tornado/test/locks_test.py index 49e6199cc..73f0f5911 100644 --- a/tornado/test/locks_test.py +++ b/tornado/test/locks_test.py @@ -206,6 +206,15 @@ class TestEvent(AsyncTestCase): e.set() self.assertTrue(e.is_set()) + def test_event_wait_clear(self): + e = locks.Event() + f0 = e.wait() + e.clear() + f1 = e.wait() + e.set() + self.assertTrue(f0.done()) + self.assertTrue(f1.done()) + if __name__ == '__main__': unittest.main()