简体   繁体   中英

How to send data from main process to a specific sub-process in Python Multiprocess

I use multiprocessing.Process in Win10 Python to create multiple sub-processes to run a function in parallel, where each sub-process waits for the data from main-process the complete the whole task. I know that using multiprocessing.Queue() can realize the communication between main process and sub-process. However, it doesn't specify which sub-process can get the data. It happens that sub-process-7 gets the data, which I intend to send to sub-process-2. Is there a way to specify sending data to a specific sub-process?

If you want to control which process should get a message use dedicated queues. Create a queue queue2 and pass that to sub-process-2.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM