python多处理队列:是否独立于获取? [英] python multi-processing queue: is putting independent from getting?
本文介绍了python多处理队列:是否独立于获取?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
putting
是 多处理队列 是否与getting
对象无关?
换句话说,如果另一个进程 P2 来自某个对象,则putting
该对象会阻止该进程 P1 吗?
In other words, will putting
an object block the process P1 if another process P2 is getting
from it?
更新:我假设一个无限队列.
推荐答案
我对源代码的了解是get
获得了读取锁,该读取锁与get
可以互相阻塞,并且并发put
可以互相阻塞(对block
参数的使用取模),但这不会相互阻塞.
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 get
s can block each other, and concurrent put
s can block each other (modulo your use of the block
parameter), but that gets and puts do not mutually block.
这篇关于python多处理队列:是否独立于获取?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文