简体   繁体   中英

In Python, how can I send a Queue to a multiprocessing.Process after it has already been started?

Typically I do something like:

q = Queue()
p = Process(target=f, args=(q,))
p.start()

Is there some way to pass p another Queue? Er... now that I think about it - can this be done through q?

  1. Yes, it can be done via q . You can pass any object there, another Queue included
  2. I wouldn't recommend this practice, however. Describe why you originally need this, maybe there's a better design.

No, once a process has been created (the process is forked), queues can no longer be sent to it. They can only be sent at process creation time. To do otherwise results in an exception.

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