python - 什么是 gevent.queue.Channel?

标签 python queue gevent channel

在 Gevent 的 what's new 下, 一个新类 Channelgevent.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, its put method always blocks until the item is delivered. (This is unlike the standard Queue, 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/

相关文章:

python - 如何使用 Mimemultipart 在 Python 中发送邮件

python - 结果稀疏性已知时的稀疏矩阵乘法(在 python|scipy|cython 中)

c++ - 如何获得队列的最小值和最大值?

javascript - 为基于 SQS 的工作人员设置 future 某个日期的任务?

python - 使用 Gevent/Tornado 和 Flask 的 Socket.io 处理程序

python - PyPy 和 PyPy + greenlet 中的 Stackless - 差异

python - 直方图的边缘检测 - python

PHP Exec() 和 Python 脚本的可伸缩性

c++ - 队列不添加对象 - C++ 11

python - 如何正确定义 gevent 功能是否可用?