The problem is not that in this case it cannot be foiled - if you use a Unix-like platform, the queue can be passed on to the child without etching. (On Windows, I think you get an etching error here). The root problem is that you are not using a process safe queue. The only queues that can be used between processes are Queue objects that live inside the multiprocessing module. Unfortunately, there is no PriorityQueue implementation. However, you can easily create it by registering PriorityQueue with the multiprocessing.Manager class, for example:
import time from multiprocessing import Process from multiprocessing.managers import SyncManager from Queue import PriorityQueue class MyManager(SyncManager): pass MyManager.register("PriorityQueue", PriorityQueue)
Output:
worker 100 main 100
Note that this probably won't work as well as if it were a standard subclass of multiprocessing.Queue . Manager -based Manager is implemented by creating a Manager server process that actually contains a regular PriorityQueue , and then provides your core and Proxy workflows that use IPC to read / write to the queue in the server process. The usual multiprocessing.Queue just writing / reading data to / from Pipe . If this is a concern, you can try to implement your own multiprocessing.PriorityQueue by subclassing or delegating from multiprocessing.Queue . However, this may not be worth the effort.
source share