9

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

3
  • 1
    Can you give an example of code exhibiting the issue? I've quickly read a few things about this and I think by inheritance they mean inheritance from a parent process (if so its definitely confusing). I found some examples using multiprocessing.Manager to avoid the error. Commented Jan 18, 2016 at 4:46
  • 1
    See here. quote: It is possible to create shared objects using shared memory which can be inherited by child processes. Commented Jan 18, 2016 at 4:49
  • I think the confusion is the word inheritance. They mean inheritance between processes, and not classes. Commented Jul 11, 2017 at 15:26

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.