Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Queue objects should only be shared between processes through inheritance

I have two python classes that share a base class that let's say defines a multiprocessing.Queue.

Each of those classes will be launched on a separate subprocess and need to share info through a queue.

Now, if the base class defines a Queue, then each subclass object will instantiate it's own queue, making the sharing of queue elements impossible. But then again I find this documented

Queue objects should only be shared between processes through inheritance. 

So what's the proper way of sharing a Queue between subprocesses and how does the above sentence even make sense?

Note that I can obviously pass a reference to the queue at initialization of the subprocesses but I'd like to takle this problem using inheritance

like image 728
Kam Avatar asked Jan 18 '16 04:01

Kam


1 Answers

So what's the proper way of sharing a Queue between subprocesses and how does the above sentence even make sense?

The sentence makes sense when you are talking about inheritance between processes, like child and parent processes. It is NOT about classes and inheritance in Object Oriented Programming.


For the proper way of using queues, look at this or this for example.

like image 188
Mahdi Avatar answered Nov 01 '22 02:11

Mahdi