python多处理队列:是否独立于获取? [英] python multi-processing queue: is putting independent from getting?

查看:62
本文介绍了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获得了读取锁,该读取锁与_notempty)无关. >.如果我理解正确,并发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 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.

这篇关于python多处理队列:是否独立于获取?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆