tornado.queues – Queues for coroutines¶
4.2 新版功能.
-
exception
tornado.queues.QueueEmpty[源代码]¶ Raised by
Queue.get_nowaitwhen the queue has no items.
-
exception
tornado.queues.QueueFull[源代码]¶ Raised by
Queue.put_nowaitwhen 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.TimeoutErrorafter 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.TimeoutErrorafter 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
getused to fetch a task, a subsequent call totask_donetells the queue that the processing on the task is complete.If a
joinis blocking, it resumes when all items have been processed; that is, when everyputis matched by atask_done.Raises
ValueErrorif called more times thanput.
-
join(timeout=None)[源代码]¶ Block until all items in the queue are processed.
Returns a Future, which raises
tornado.gen.TimeoutErrorafter a timeout.
-