-
-
Notifications
You must be signed in to change notification settings - Fork 29.9k
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.Barrier does not return if waiting process is terminated (tested on windows) #123899
Comments
Bug confirmed(on Linux) |
Just wondering, but can you reproduce the issue without the logging part? |
Just tested without logging, same behavior as before. (as expected) |
@picnixz would you mind assigning this issue to me (lol |
Upon thorough investigation of this issue, I believe it should be classified as a missing feature rather than a bug. Specifically, we need to implement a
I'm currently considering whether to open a feature request on discuss.python.org for this enhancement. cc @picnixz |
Barrier class already has a |
I'm also a little confused, it seem that the problem is about killing process gracefully without causing deadlock, not about requesting new features from
multiprocessing.Barrier is just a clone of threading.Barrier, which has all the necessary routines including As far as i see, before |
You are right, the I think we should add timeout for the |
Killing the process was just used to demonstrate the effect, it's not the real use case... In general I used multiprocessing to separate processes with unreliable third-party binary libraries that can cause access violation in case of e.g. HW defects. Access Violation causes the processes to get killed. |
Yes, this is the normal circumstance. But in some circumstances, like kill the process in GUI process or killed by systemed. we can't clean the code before the process exist. So for now, the |
Bug report
Bug description:
I'm using
multiprocessing.Barrier
to synchronize processes. The individual processes might get terminated/killed by a GUI user interaction.In case that a process, that already entered the waiting state, is killed, the barrier will never be released, a timeout is not taken into account.
When debugging this issue I realized that it is cause by
cpython/Lib/multiprocessing/synchronize.py
Line 297 in b52de7e
self._woken_count
is notreleased
by the terminated process and no timeout is specified in the call toself._woken_count.acquire()
If I add a (hardcoded...) timeout to
self._woken_count.acquire(True, 2.0)
the program continues as expected.I hope that there a better approaches to fix this than using a hardcoded timeout...
Example script to reproduce error.
CPython versions tested on:
3.12
Operating systems tested on:
Windows
The text was updated successfully, but these errors were encountered: