Skip to content Skip to sidebar Skip to footer

Python Multiprocessing - How To Make Processes Wait While Active?

Well, I'm quite new to python and multiprocessing, and what I need to know is if there is any way to make active processes wait for something like 'all processes have finished usin

Solution 1:

I'm not sure, that I understood your question. But I think you can use Queue. It's good solution to transmit data from one process to another. You can implement something like:

1. Process first chunk
2. Write results to queue
3. Waits until queue is not full
4. Returns to 1

Solution 2:

I actually found out a way to do what I wanted. As you can see in the question, the code was using a manager along the processes. So, in simple words, I made a shared resource which works basically like a "Log". Every time a process finishes its work, it writes a permission in the log. Once all the desired permissions are there, the processes continue their works (also, using this, I could set specific orders of access for a resource, for example). Please note that this is not a Lock or a Semaphore. I suppose this isn't a good method at all, but it suits the problem's needs and doesn't delay the execution.

Post a Comment for "Python Multiprocessing - How To Make Processes Wait While Active?"