python multi-processing queue: is putting independent from getting?

蹲街弑〆低调 提交于 2019-12-08 03:25:52

问题


Is putting an object in a multi-processing queue independent from getting an object from it?

In other words, will putting an object block the process P1 if another process P2 is getting from it?

Update: I am assuming an infinite queue.


回答1:


My reading of the source code is that get obtains a read lock, which is independent of of the lock (called _notempty) acquired by put. If I understand correctly, concurrent gets can block each other, and concurrent puts can block each other (modulo your use of the block parameter), but that gets and puts do not mutually block.



来源:https://stackoverflow.com/questions/2275108/python-multi-processing-queue-is-putting-independent-from-getting

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!