-
-
Notifications
You must be signed in to change notification settings - Fork 30.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
multiprocessing.Event.wait hangs when interrupted by signal that sets the event #85772
Comments
According to the docs, multiprocessing.Event is a clone of threading.Event. Yet, there is a strange behavior that is observed only on multiprocessing.Event. If an event.wait() is interrupted by a SIGINT and the signal handler sets the event, then the call to event.set() hangs if event is an instance of multiprocessing.Event, in what looks like a deadlock; instead, it works as expected if it's an instance of threading.Event. See the file attached for a reproduction. It seems to have been so for a long time, see: https://stackoverflow.com/questions/24422154/multiprocessing-event-wait-hangs-when-interrupted-by-a-signal/30831867 |
I just spent a lot of time with this problem. I have a multiprocessing.Event that sleeps the MainThread of a child process and an interrupt handler that sets that event. As described here, when the interrupt triggers the event, the process hangs. Doing some research on the web, including on the cited stackoverflow topic, I got the following solution: Solutions for Linux with fork start method:
Solution for Linux with spawn start method
Windows:
Reference: https://docs.microsoft.com/en-us/windows/console/setconsolectrlhandler
|
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: