Skip to content
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

Replace multiprocessing.Queue with Manager.Queue #96

Open
xin-huang opened this issue Feb 5, 2024 · 0 comments
Open

Replace multiprocessing.Queue with Manager.Queue #96

xin-huang opened this issue Feb 5, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@xin-huang
Copy link
Owner

In a separate project, I experienced deadlocks when using multiprocessing.Queue.

I found a solution by switching to Manager.Queue, as recommended in the Python documentation:

Warning

As mentioned above, if a child process has put items on a queue (and it has not used JoinableQueue.cancel_join_thread), then that process will not terminate until all buffered items have been flushed to the pipe.

This means that if you try joining that process you may get a deadlock unless you are sure that all items which have been put on the queue have been consumed. Similarly, if the child process is non-daemonic then the parent process may hang on exit when it tries to join all its non-daemonic children.

Note that a queue created using a manager does not have this issue. See Programming guidelines.

Although I have not encountered deadlocks in dadi-cli, I suggest switching from multiprocessing.Queue to Manager.Queue to avoid potential deadlock issues.

from multiprocessing import Process, Queue

@xin-huang xin-huang self-assigned this Feb 5, 2024
@RyanGutenkunst RyanGutenkunst added the enhancement New feature or request label Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants