Why does this queue behave like this?

后端 未结 1 1146
南旧
南旧 2021-01-28 23:46

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

相关标签:
1条回答
  • 2021-01-29 00:15

    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.

    1. 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. ...
    0 讨论(0)
提交回复
热议问题