spdl.pipeline.AsyncQueue¶
- class AsyncQueue(name: str, buffer_size: int = 0)[source]¶
Extends
asyncio.Queue
with init/finalize logic.When a pipeline stage starts,
PipelineBuilder
callsstage_hook()
method, and the initialization logic is executed. During the execution of the pipeline,get
/put
methods are used to pass data. At the end of pipeline execution, the finalization logic instage_hook()
is executed.One intended usage is to overload the
get
/put
methods to capture the time each pipeline stage waits, then publish the stats. This helps identifying the bottleneck in the pipeline. SeeStatsQueue
.- Parameters:
name – The name of the queue. Assigned by
PipelineBuilder
.buffer_size – The buffer size. Assigned by
PipelineBuilder
.
Methods
empty
()Return True if the queue is empty, False otherwise.
full
()Return True if there are maxsize items in the queue.
get
()Remove and return an item from the queue.
get_nowait
()Remove and return an item from the queue.
join
()Block until all items in the queue have been gotten and processed.
put
(item)Put an item into the queue.
put_nowait
(item)Put an item into the queue without blocking.
qsize
()Number of items in the queue.
Context manager, which handles init/final logic for the stage.
task_done
()Indicate that a formerly enqueued task is complete.
Attributes
maxsize
Number of items allowed in the queue.
- stage_hook() AsyncIterator[None] [source]¶
Context manager, which handles init/final logic for the stage.