在 Gevent 的 what's new 下, 一个新类 Channel
在gevent.queue
下提到模块:
Queue(0) is now equivalent to an unbound queue and raises DeprecationError. Use gevent.queue.Channel if you need a channel.
我查看了文档页面,但没有关于Channel
是什么或做什么的文档。看着 source ,它看起来类似于 Queue
但它不是它的子类。 Channel
的目的或用途究竟是什么?它是某种专门的队列吗?
最佳答案
查看the code for the pre-1.0 version of Gevent告诉您什么是 Channel
(尽管我知道这有点令人费解):
Queue(0)
is a channel, that is, itsput
method always blocks until the item is delivered. (This is unlike the standardQueue
, where 0 means infinite size).
现在,正如发行说明所示,此行为在 Gevent 1.0 中已更改,Queue(0)
不再以这种方式工作:Channel()
可以。
因此,您会发现 Channel.put
的实现比 Queue.put
的实现复杂得多。
请注意,“标准队列
”指的是the standard library Queue .
关于python - 什么是 gevent.queue.Channel?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27447778/