#! /usr/bin/python # Script demonstrating how modifying an object straight after en-queueing it # can result in the modified object being added to the queue (only affects # multiprocessing.Queue and inheriting multiprocessing.JoinableQueue). from multiprocessing import Process from multiprocessing.queues import SimpleQueue, Queue, JoinableQueue from time import sleep def queueChild(q): l = list(xrange(10000)) q.put(l) #sleep(.5) # With this delay both queue types behave the same l[-1] = None if __name__ == '__main__': for queueClass in (SimpleQueue, Queue, JoinableQueue): q = queueClass() p = Process(target = queueChild, args = (q,)) p.start() result = q.get() p.join() print "\n", str(queueClass), "\nFinal value in queue:", result[-1]