tornado.queues
– Queues for coroutines¶
4.2 新版功能.
-
exception
tornado.queues.
QueueEmpty
[源代码]¶ Raised by
Queue.get_nowait
when the queue has no items.
-
exception
tornado.queues.
QueueFull
[源代码]¶ Raised by
Queue.put_nowait
when a queue is at its maximum size.
-
class
tornado.queues.
Queue
(maxsize=0)[源代码]¶ Coordinate producer and consumer coroutines.
If maxsize is 0 (the default) the queue size is unbounded.
-
maxsize
¶ Number of items allowed in the queue.
-
put
(item, timeout=None)[源代码]¶ Put an item into the queue, perhaps waiting until there is room.
Returns a Future, which raises
tornado.gen.TimeoutError
after a timeout.
-
put_nowait
(item)[源代码]¶ Put an item into the queue without blocking.
If no free slot is immediately available, raise
QueueFull
.
-
get
(timeout=None)[源代码]¶ Remove and return an item from the queue.
Returns a Future which resolves once an item is available, or raises
tornado.gen.TimeoutError
after a timeout.
-
get_nowait
()[源代码]¶ Remove and return an item from the queue without blocking.
Return an item if one is immediately available, else raise
QueueEmpty
.
-
task_done
()[源代码]¶ Indicate that a formerly enqueued task is complete.
Used by queue consumers. For each
get
used to fetch a task, a subsequent call totask_done
tells the queue that the processing on the task is complete.If a
join
is blocking, it resumes when all items have been processed; that is, when everyput
is matched by atask_done
.Raises
ValueError
if called more times thanput
.
-
join
(timeout=None)[源代码]¶ Block until all items in the queue are processed.
Returns a Future, which raises
tornado.gen.TimeoutError
after a timeout.
-