PythonQueue.Queue.get方法

2024-05-23 20:52:02 发布

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

在python文档中,它说

exception Queue.Empty
Exception raised when non-blocking get() (or get_nowait()) is called on a Queue object which is empty.

所以我想知道下面的代码是否会提高队列。空异常,因为它使用“get”方法的方式似乎没有阻塞。在

这是密码。在

try:
    request = self._requests_queue.get(True, self._poll_timeout)
except Queue.Empty:
    continue

Tags: or文档selfgetqueueisexceptionblocking
1条回答
网友
1楼 · 发布于 2024-05-23 20:52:02

documentation表示回答问题所需的所有信息(强调我的):

Queue.get([block[, timeout]])

Remove and return an item from the queue. If optional args block is true and timeout is None (the default), block if necessary until an item is available. If timeout is a positive number, it blocks at most timeout seconds and raises the Empty exception if no item was available within that time. Otherwise (block is false), return an item if one is immediately available, else raise the Empty exception (timeout is ignored in that case).

相关问题 更多 >