是什么gevent.queue.Channel?

2024-06-17 08:53:58 发布

您现在位置:Python中文网/ 问答频道 /正文

在Gevent的what's new下,^{}模块下的一个新类^{}

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的目的或用途是什么?它是某种特殊的队列吗?在


Tags: 模块to文档annewqueueischannel
1条回答
网友
1楼 · 发布于 2024-06-17 08:53:58

the code for the pre-1.0 version of Gevent可以告诉你Channel是什么(尽管我知道这有点复杂):

Queue(0) is a channel, that is, its put method always blocks until the item is delivered. (This is unlike the standard Queue, where 0 means infinite size).

现在,正如发行说明所指出的,这种行为在gevent1.0中已经改变了,Queue(0)不再以这种方式工作:Channel()就这样了。在

您将看到,相应地,Channel.put的实现比Queue.put的实现复杂得多。在

注意,“标准Queue”指的是the standard library Queue。在

相关问题 更多 >