Skip to main content

A task queue for parallel processing

Project description

tasq.py

A parallel safe task queue on disk.

About

tasq.py maintains a database of tasks and let you claim and mark tasks as done in a multi-process safe way. It has two backends, a sqlite based one for general single machine multi-process use, and a file based one for multi-machine multi-process use (on a shared filesystem).

Usage

A task is only defined as a string of text, or name, that should be unique. The interpretation of the name is up to the user.

To create a new task queue, use init and provide the first list of task from a file or stdin:

$ tasq init tasks.db - <<EOF
./work/task1 3
./work/task2 9

# comments and empty lines are ignored
./work/task3 0 # inline comments work too
EOF

Tasks can be added later in a similar fashin with add:

$ tasq add tasks.db - <<EOF
./work/task4 blublublu
./work/task5 "it uses shlex so spaces are ok"
./work/task6 blablabla
EOF

To see the current state of the queue, use list:

$ tasq list tasks.db
a6cc64a4401b4e0a94489b43bd22ac72 pending 2025-11-22 21:53:31 ['./work/task1', '3']
390dda92b89f4b4a9ed519fc86356fd7 pending 2025-11-22 21:53:31 ['./work/task2', '9']
a2380735393e4f07a7b4b67eb7a969eb pending 2025-11-22 21:53:31 ['./work/task3', '0']
482955a8421940a5b4874d4987affb30 pending 2025-11-22 21:53:37 ['./work/task4', 'blublublu']
1d875235a5a64d16921fa9d5e0d54309 pending 2025-11-22 21:53:37 ['./work/task5', 'it uses shlex so spaces ar
e ok']
b030397203a94303b1a6a1960ba78aaf pending 2025-11-22 21:53:37 ['./work/task6', 'blablabla']

The hex string at the begining is a unique identifier for the task that is used to interact with it.

Tasks can be claimed using claim:

$ tasq claim tasks.db -n 2 --data
390dda92b89f4b4a9ed519fc86356fd7 ["./work/task2", "9"]
a6cc64a4401b4e0a94489b43bd22ac72 ["./work/task1", "3"]

and marked done with done:

$ tasq done tasks.db a6cc64a4401b4e0a94489b43bd22ac72

See also tasq help for more commands.

There is also a second script pll that does something similar to GNU parallel but for a task queue.

For example the following command:

$ pll tasks.db -n 2 ./process.sh '{0}' '{1}'

will process all tasks calling the command ./process.sh with the task arguments (placeholder follow str.format syntax) using two parallel workers. The outputs will be printed concatenates with # <TASK_ID> line above each outputs. Because it uses the task queue, you can have more than one pll running in parallel (for example if using slurm, each slurm job can use pll).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tc4v_tasq-0.1.0.tar.gz (15.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tc4v_tasq-0.1.0-py3-none-any.whl (17.0 kB view details)

Uploaded Python 3

File details

Details for the file tc4v_tasq-0.1.0.tar.gz.

File metadata

  • Download URL: tc4v_tasq-0.1.0.tar.gz
  • Upload date:
  • Size: 15.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.7

File hashes

Hashes for tc4v_tasq-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e2b1ea5454e99eb74c888087240c08e75de2e59395f934777dbdf595a9e704d1
MD5 fd9dbe023806044ce5c3fb2da015f8d5
BLAKE2b-256 a585d68ed6c56790f3413703d44c691946b231f54ee1e58f1d739a7249065bd6

See more details on using hashes here.

File details

Details for the file tc4v_tasq-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: tc4v_tasq-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 17.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.7

File hashes

Hashes for tc4v_tasq-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 26a62a81981ec3ff728f8a96137d08b5bce8603cabc481b59033640e4690abf9
MD5 04a319d21b0c6a1510399a05b3ec95ce
BLAKE2b-256 f26a64c71804c7b81e141dc0248225692440a3277387ac45acffe12c8254e90e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page