默认情况下 python 的多处理队列 "infinite" 是吗?

Is python's multiprocessing Queue "infinite" by default?

python 的多处理队列的文档:https://docs.python.org/2/library/multiprocessing.html#multiprocessing.Queue

不如 queue.Queue 的清晰:https://docs.python.org/3/library/queue.html

当 maxsize 参数没有给构造函数。

是这样吗?

multiprocessing.Queue 完全模仿 queue.Queue 的所有功能(.task_done().join() 除外)

Queue implements all the methods of Queue.Queue except for task_done() and join().

所以没有参数(或负数)它可以取无限个元素

(作为旁注,因为队列在内部是类似列表的结构(dequeueheapqlist))很难有限制,然后没有限制限制。)

编辑:

好的,查看源代码后发现,如果没有指定值,multiprocessing.Queue确实有一个标准的上限:2**31-1

# file multiprocessing/queues.py
class Queue(object):
    def __init__(self, maxsize=0, *, ctx):
        if maxsize <= 0:
            from .synchronize import SEM_VALUE_MAX as maxsize # -> 2**31-1

所以它不是无穷大,但实际上是无穷大