I\'m writing an object which draws from a multiprocessing queue, and I found that when I run this code, I get data = []
. Whereas if I tell the program to sleep for
It's mentioned in the docs for multiprocessing.Queue
Note When an object is put on a queue, the object is pickled and a background thread later flushes the pickled data to an underlying pipe. This has some consequences which are a little surprising, but should not cause any practical difficulties – if they really bother you then you can instead use a queue created with a manager.
- After putting an object on an empty queue there may be an infinitesimal delay before the queue’s empty() method returns False and get_nowait() can return without raising Queue.Empty. ...