Skip to main content

Distributed Python task execution via automatic function serialization

Reason this release was yanked:

Version number broke some tests

Project description

offwork

PyPI Python 3.11+ License: AGPL-3.0 Typed Zero Dependencies

Run any Python function on a remote worker with just two lines of code.

Put .connect() somewhere at the start of your script, add @offwork.task to your function, that's it. You can now run it remotely — no shared codebase, no deployment pipeline.

offwork captures its entire dependency graph (helpers, imports, closures, constants) and ships it to the worker as a self-contained payload. The worker doesn't need to have any prior knowledge of your code.

Quick start

pip install offwork
offwork worker --backend local://localhost:9748 --tmp  # start a worker in a temp venv
import asyncio, math, offwork

offwork.connect("local://localhost:9748")

def add(a: float, b: float) -> float:
    return a + b

@offwork.task  # only the entry point needs this - add() is captured automatically
def hypotenuse(a: float, b: float) -> float:
    return math.sqrt(add(a**2, b**2))

async def main():
    print(await hypotenuse.run(3.0, 4.0))  # 5.0

asyncio.run(main())

.run() serializes the function graph, submits it to the worker, and returns the result. The worker reconstructs source, installs any missing packages, and executes.

Multi-machine

Swap local:// for Redis or RabbitMQ to run on a remote worker:

pip install offwork[redis]
offwork worker --backend redis://other-machine:6379

Features

Async-native .run(), .submit(), .map(), asyncio.gather — all coroutines
Scheduling submit(run_in=delay), submit(run_at=dt), submit(run_every=interval) with cancellation
Retry & timeout @offwork.task(timeout=30, retries=3) with exponential backoff
Throttling @offwork.task(throttle=timedelta(hours=24)/50) — rate-limit executions
Progress & cancellation offwork.progress(3, 10) inside tasks; fut.cancel() / await fut.cancel() on client
Heartbeat & stall detection Workers heartbeat every second; clients raise TaskStalled on silence
Package auto-install Workers pip install missing packages before execution
Docker sandbox Optional container isolation, fully transparent to clients
Signed execution Pre-shared token or PIN pairing + HMAC-SHA256 task authentication
... See Features for more information.

Security

Signing

To make sure your worker only executes trusted code, use --require-signing.
Configure a shared token or pair interactively with a PIN. See Signing & Pairing for details.

# Token (CI/CD)
offwork token generate
export OFFWORK_SIGNING_TOKEN=<token>                         # client & worker
offwork worker --backend redis://localhost:6379 --require-signing

# PIN pairing (interactive)
offwork worker --backend redis://localhost:6379 --pair       # shows 6-digit PIN
offwork pair --backend redis://localhost:6379                # client: enter PIN

After pairing, tasks are signed automatically with no client code changes. See Signing & Pairing.

Sandbox

To avoid side-effects on the worker machine, run tasks inside Docker containers:

offwork sandbox setup                                      # build image (once)
offwork worker --backend redis://localhost:6379 --sandbox  # run with isolation

See Sandbox for configuration.

Documentation

Features Full feature guide and API walkthrough
Technical Overview Architecture, serialization format, internals
Signing & Pairing Cryptographic task signing protocol
Sandbox Docker container isolation

Examples

offwork worker --backend local://localhost:9748 --tmp  # start worker
offwork run examples/remote_execution.py              # run any example

See examples/README.md for a guide to all examples.

License

AGPL-3.0

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

offwork-0.2.0.tar.gz (109.3 kB view details)

Uploaded Source

Built Distribution

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

offwork-0.2.0-py3-none-any.whl (129.8 kB view details)

Uploaded Python 3

File details

Details for the file offwork-0.2.0.tar.gz.

File metadata

  • Download URL: offwork-0.2.0.tar.gz
  • Upload date:
  • Size: 109.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for offwork-0.2.0.tar.gz
Algorithm Hash digest
SHA256 b87b71955924cb6e7c1c5fc6618def9e9eecbf1b59fb6e7e633e4a32c1e36e3c
MD5 08af1f33b8e658d44a386ce0e0590a43
BLAKE2b-256 af92e0c44348c3c37266d61cc055c2557d944583f228b43f532b079e18b0d72a

See more details on using hashes here.

File details

Details for the file offwork-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: offwork-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 129.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for offwork-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8f86e2d00b2c60c6f2acafa16cfd6347c4be478a672c41279755e1dff31c429c
MD5 7048cebd6eaa8c1168627bcd618afdb2
BLAKE2b-256 90d2c21468f4367022eed2f5a7af5144e9c9e1dac810fd8c8581c631c4fd0bd0

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