Created
May 22, 2014 15:27
-
-
Save SonOfLilit/ad0a90b14cfad96badaf to your computer and use it in GitHub Desktop.
Python bug?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
$ python event_test.py | |
Traceback (most recent call last): | |
File "event_test.py", line 14, in <module> | |
assert value | |
AssertionError | |
Exception in thread Thread-1 (most likely raised during interpreter shutdown): | |
""" | |
from threading import Thread, Event | |
event = Event() | |
class Toggler(Thread): | |
daemon = True | |
def run(self): | |
while True: | |
event.set() | |
event.clear() | |
Toggler().start() | |
while True: | |
value = event.wait() | |
assert value |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://docs.python.org/2/library/threading.html#threading.Event.wait
wait([timeout])
Block until the internal flag is true. If the internal flag is true on entry, return immediately. Otherwise, block until another thread calls set() to set the flag to true, or until the optional timeout occurs.
When the timeout argument is present and not None, it should be a floating point number specifying a timeout for the operation in seconds (or fractions thereof).
This method returns the internal flag on exit, so it will always return True except if a timeout is given and the operation times out.
Changed in version 2.7: Previously, the method always returned None.