The title of this post pretty much sums up my question - will threads waiting on an
Note that it's not necessarily the case that waiting for an
Event implies the
Event isn't in trash. Cyclic trash is one possibility, and here's another:
import threading class C(object): def __init__(self): self.e = threading.Event() def __del__(self): print("going away") def f(): C().e.wait() t = threading.Thread(target=f) t.start() print("main ending")
going away main ending
and then it hangs forever, as Python attempts to
.join() the thread as part of interpreter shutdown processing.
f(), run in a thread, creates an instance of
C that becomes trash immediately after its
e attribute is retrieved. So its
__del__ method is called, and "going away" is displayed.
You can infer from the behavior that, no, a trash
Event does not get set by magic. But it's not going to come up in practice, so don't worry about it ;-)