[issue41714] multiprocessing.Queue deadlock

Richard Purdie report at bugs.python.org
Fri Sep 4 07:43:44 EDT 2020


Richard Purdie <richard.purdie at linuxfoundation.org> added the comment:

Even my hack to call _writer.close() doesn't seem to be enough, it makes the problem rarer but there is still an issue. 
Basically, if you call cancel_join_thread() in one process, the queue is potentially totally broken in all other processes that may be using it. If for example another has called join_thread() as it was exiting and has queued data at the same time as another process exits using cancel_join_thread() and exits holding the write lock, you'll deadlock on the processes now stuck in join_thread() waiting for a lock they'll never get.
I suspect the answer is "don't use cancel_join_thread()" but perhaps the docs need a note to point out that if anything is already potentially exiting, it can deadlock? I'm not sure you can actually use the API safely unless you stop all users from exiting and synchronise that by other means?

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue41714>
_______________________________________


More information about the Python-bugs-list mailing list