Skip to main content

taskq

Priority queue with task categorisation support

Current build status Latest PyPI version

Overview

taskq is a heap based priority queue that adds support to partition tasks into categories for selective removal.

The main driver for the project was work/task queueing where jobs need to be distributed to workers with different capabilities and non-uniform processing times (for calculating efficient prefetch).

This library is not thread-safe and is not intended as a replacement for python’s queue.Queue class.

Getting Started

Install using pip:

pip install taskq

Basic FIFO usage:

>>> from taskq import Queue
>>> q = Queue()
>>> q.push('task1')
>>> q.push('task2')
>>> q.pop()
'task1'
>>> q.pop()
'task2'

Task priorities (complex types that define __cmp__ are also supported):

>>> from taskq import Queue
>>> q = Queue()
>>> q.push('task1', 2)
>>> q.push('task2', 1)
>>> q.pop()
'task2'
>>> q.pop()
'task1'

Multi-pop:

>>> from taskq import Queue
>>> q = Queue()
>>> q.push('task1')
>>> q.push('task2')
>>> q.push('task3')
>>> q.pop(2)
['task1', 'task2']

Task categories:

>>> from taskq import Queue
>>> q = Queue()
>>> q.push('task1', category='foo')
>>> q.push('task2', category='bar')
>>> q.push('task3', category='foo')
>>> q.pop(2, categories=['dog', 'foo'])
['task1', 'task2']

Category ratios:

>>> from taskq import Queue
>>> q = Queue()
>>> q.push('task1', category='foo')
>>> q.push('task2', category='bar')
>>> q.push('task3', category='foo')
>>> q.pop(2, categories=['bar', 'foo'], ratios=[1, 0.5])
['task1', 'task2', 'task3']

The above example is useful when prefetching/distributing tasks that have non-uniform processing durations. If the category ratios represent average duration in seconds, the count can be used to pull approximately count seconds worth of the higest priority tasks from the queue.

See source documentation for other feature examples.

Issues

Source code for taskq is hosted on GitHub. Any bug reports or feature requests can be made using GitHub’s issues system.

Metadata

Release files for taskq 0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for taskq 0.3
File Size Uploaded Provenance Actions
taskq-0.3.tar.gz 16.8 kB Without provenance Details for taskq-0.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for taskq 0.3
File Interpreter ABI Platform Actions
taskq-0.3-py2.py3-none-any.whl Python 3, Python 2 none any Details for taskq-0.3-py2.py3-none-any.whl

Total release size: 25.6 kB

Release files / taskq-0.3.tar.gz

Download URL taskq-0.3.tar.gz
Size 16.8 kB
Tags Source
SHA-256 checksum
How to use checksums
24ce799f0359d2d7081b12fcdab31adf3b5cda2886ba9000f9c09f627541c16f
BLAKE2b-256 checksum
How to use checksums
83416b4bb212e1fd91ff114057056dc0e8b58fb0972293ccf5442b6767829059
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / taskq-0.3-py2.py3-none-any.whl

Download URL taskq-0.3-py2.py3-none-any.whl
Size 8.8 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
bc8c7b5f5ea17127d93dae804acd0ddd036e6505c0e28a936b0dbd73484fe9c3
BLAKE2b-256 checksum
How to use checksums
c3fb47c7cf62789ec3fcd90d462f5b8691fe448586eebe40bcb202fd0098850a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for taskq 0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.3 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page