How to exchange objects between processes
The development of parallel applications has the need for the exchange of data between processes. The multiprocessing library has two communication channels with which it can manage the exchange of objects: queues and pipes.
Using queue to exchange objects
As explained before, it is possible for us to share data with the queue data structure.
A queue returns a process shared queue, is thread and process safe, and any serializable object (Python serializes an object using the pickable module) can be exchanged through it.
How to do it...
In the following example, ...
Get Python Parallel Programming Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.