zaku.client
TaskQ Client#

class zaku.TaskQ[source]#

Bases: PrefixProto

TaskQ Client#

This is the client that interacts with the TaskQ server. We do not include the configs in the command line because the TaskServer is the primary entry point from the command line.

We do provide the option to load environment variables for these configurations.

Usage#

# Put this into an .env file (without the exports)
export ZAKU_URI=http://localhost:9000
export ZAKU_QUEUE_NAME=jq-debug-1

Now you can create a queue like this:

queue = TaskQ()
Out[2]: {
    "uri": "http://localhost:9000",
    "name": "jq-debug-1",
    "ttl": 5.0
}
init_queue(name=None)[source]#

Create a new collection.

Parameters:

name – (optional) The name of the queue.

add(value: Dict, *, key=None)[source]#

Append a job to the queue.

Parameters:

value (Dict) –

take()[source]#

Grab a job that has not been grabbed from the queue.

pop()[source]#

Pop a job from the queue.

mark_done(job_id)[source]#

Mark a job as done.

mark_reset(job_id)[source]#
uri = 'http://localhost:9000'#

host endpoint uri, including protocol and port.

uri: str = Proto(
    "http://localhost:9000",
    env="ZAKU_URI",
)   
name = 'jq-9409e6f3-b7cd-4351-949c-67e926ed4a8f'#

This is the name of the queue. It is unique to the client. Defaults to a random uuid to avoid collision, but you usually want to supply a name so that it is easier to find the queue. Zaku also reads from environment variables to side-load the configurations.

name: str = Proto(
    f"jq-{uuid4()}",
    env="ZAKU_QUEUE_NAME",
)
ttl = 5.0#

time to live in seconds. Defaults to 5.

no_init = None#

Flag for skipping the queue creation.