Skip to main content

Overview

coverage

A simple way to ensure that a list of commands is executed successfully, or re-tried.

Tasklist allows to the following:

  • Execute lists of commands (tasks)
  • Verify their success
  • Re-execute commands that failed, order-preserving
  • Control temporary and permanent command statuses
  • Discard tasks with temporary failures after a tryout
  • Discard tasks with temporary failures after a timeout
  • Persist the list of tasks so it's reloaded when your program fails

Main applications

  • DevOps pipelines which require multiple commands to reach a desired state
  • Servers which accept operations which may fail and are required to retry them
  • Event Sourcing architectures where events are executed with commands
  • Manual processes which may be interrupted for a failure, and need to be resumed from there

Examples

Ensure complete termination of interrupted process

from tasklist import TaskList, Task

# make sure all of the following commands are executed
commands = [
    "tar cjvf maillog.tbz /var/log/maillog",
    "rm -f /var/log/maillog",
    "service myservice restart"
]

# create a tasklist
tl = TaskList()
for cmd in commands:
    tl.add(Task(cmd=cmd.split()))

if tl.run_all():
    # some task failed. Sleep a while and retry
    tl.run_all()

Manage temporary and permanent failures

import time
from tasklist import TaskList, Task

t = Task(cmd="false")
t.run()                     # False (executed with failure)
t.failed_retry()            # False (failed with non-retriable exit status)
time.sleep(10)
t.age()                     # 10 (created 10 seconds ago)

t = Task(cmd="python", args=["-c", "import sys; sys.exit(2)"])
t.run_all()                 # False
t.failed_retry()            # True (failed with retriable exit status)

Making the queue persistent

from tasklist import TaskList, Task

# automatically persist the tasklist at the given path in the filesystem
tl = TaskList(wrkdir='/tmp/mytasklist', autosync=True)
tl.add(Task(cmd="true"))
tl.add(Task(cmd="false"))
del tl

new_tl = TaskList(wrkdir='/tmp/mytasklist', autosync=True)
len(new_tl)                     # 2 tasks

Support

This is open-source software contributed by the BuddyNS team. The project is hosted at https://gitlab.com/BuddyNS/tasklist.

Please do not contact BuddyNS for support with this library. You can get general support on Python from the great people of the #python channel on the freenode IRC network.

Metadata

Release files for tasklist 1.2.1

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

Source distribution (sdist)

Source distribution for tasklist 1.2.1
File Size Uploaded
tasklist-1.2.1.tar.gz 6.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tasklist 1.2.1
File Interpreter ABI Platform
tasklist-1.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 13.9 kB

Release files / tasklist-1.2.1.tar.gz

Download URL tasklist-1.2.1.tar.gz
Size 6.5 kB
Tags Source
SHA-256 checksum
How to use checksums
bc2e2bd89c98916021c76a477d056cfe22d79128d7cd976e7271303fc4e3c9a7
BLAKE2b-256 checksum
How to use checksums
10ebd0657633f3c81ebb1f344c647dafca3853766363775ab7fdad8d6cbf115a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7

Release files / tasklist-1.2.1-py3-none-any.whl

Download URL tasklist-1.2.1-py3-none-any.whl
Size 7.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
812e44ca5e056812e987c353b9a7695fdfaf5317ff5ea3f40b03d3b1408045cd
BLAKE2b-256 checksum
How to use checksums
3e28fd9de6f3aa2ff7196d29bbdd8f3ad5746de54ac4c73f4305b037c8f0055c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7

Release history Release notifications | RSS feed

This release

1.2.1 This release

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

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