Skip to content

Commit

Permalink
Fix multiple calls to Event.clear.
Browse files Browse the repository at this point in the history
  • Loading branch information
ajdavis committed Feb 18, 2015
1 parent d2114d9 commit 1c3d22f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tornado/locks.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ def clear(self):
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.
Expand Down
9 changes: 9 additions & 0 deletions tornado/test/locks_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,15 @@ def test_event_set_multiple(self):
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()

0 comments on commit 1c3d22f

Please sign in to comment.