Skip to content

job-queue

Bounded queue with sentinel-based shutdown used between pipeline workers.

A thread-safe FIFO queue with a fixed capacity.

Wraps queue.Queue with a typed interface and the sentinel pattern for clean shutdown.

Parameters:

Name Type Description Default
capacity int

Maximum number of items the queue can hold. Producers block on put() when the queue is full.

required

get()

Get the next item. Blocks until one is available.

Returns:

Type Description
T | object

The next item, or the STOP sentinel if the producer is done.

T | object

Always check item is STOP before using the value.

put(item)

Put an item. Blocks if the queue is full.

put_stop()

Signal that no more items will be produced.

Puts the STOP sentinel. Blocks if the queue is full — this ensures the sentinel is never lost even under backpressure.

task_done()

Mark the last item returned by get() as processed.