On Tue, 23 Jul 2019 at 00:29, Mats Wichmann <m...@wichmann.us> wrote:
>
> I've got a scenario where I need to pass data in both directions of a
> multiprocessing program.
<snip>
> So... what else should I be trying to make this a little cleaner?

I think if possible it is best to set these things up as an acyclic
pipeline so the basic problem here is the two-way communication. How
about using separate processes for putting things on the worker input
queue and reading from the worker output queue?

It probably makes sense for the master process that will outlive the
others to be the one that collects the output so maybe spawn a process
at the start whose job is putting all the test instances on the input
queue. Then spawn the workers who will read the input queue and write
to the output queue. Then the master process reads from the output
queue until it's done. I think this eliminates any need for
bidirectional communication which generally simplifies things.

--
Oscar
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to