Skip to main content

Distributed Python task execution via automatic function serialization

Reason this release was yanked:

RabbitMQ broker may be broken depending on the version

Project description

offwork

Run any Python function on a remote worker — zero setup, zero deployment.

Python 3.10+ License: AGPL-3.0 Typed Zero Dependencies

Add @trace to a function. offwork captures its source, dependencies, and imports automatically. Workers reconstruct and execute everything from scratch — no shared filesystem, no deployment pipeline. Missing packages are installed on the fly.

Quick start

pip install offwork
import asyncio, math, offwork
from offwork import trace

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

def add(a, b):
    return a + b

@trace
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())

Only the entry point needs @trace — everything it calls is captured automatically.

offwork worker --backend local://localhost:9748 --tmp   # start a worker
python my_script.py                                    # → 5.0

For multi-machine, swap local:// for redis:// or an https:// managed broker URL. That's it.

Sandbox

Run tasks inside Docker containers for isolation — transparent to clients:

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

See Sandbox for configuration and management.

Signing

Pre-shared token or PIN-based pairing + HMAC-SHA256 — workers reject untrusted or tampered tasks:

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

# PIN-based pairing (interactive)
offwork worker --backend redis://localhost:6379 --pair       # displays a 6-digit PIN
offwork pair --backend redis://localhost:6379                # on client: enter the PIN

After setup, tasks are signed automatically. No client-side code changes. See Signing & Pairing for details.

Features

Auto dependency capture Functions, classes, constants, closures — recursive AST analysis
Package auto-install Workers pip install missing packages before execution
Async-native .run(), .start(), .map(), asyncio.gather
Retry & timeout @trace(timeout=30, retries=3) with exponential backoff
Scheduling .run_in(delay), .run_at(datetime), .run_every(freq) with cancellation
Throttling @trace(throttle=timedelta(hours=24)/50) — rate-limit executions
Progress & cancellation offwork.progress(3, 10) inside tasks; await future.cancel() on client
Heartbeat & stall detection Workers heartbeat; clients raise TaskStalled on silence
Content-hash caching Same code = cache hit, regardless of client
Pluggable backends local:// (same-machine TCP), redis://, amqp:// (RabbitMQ), http:///https:// (hosted broker API)
Docker sandbox Container isolation, transparent to clients
Signed execution Pre-shared token or PIN pairing + HMAC-SHA256 task authentication
Graceful shutdown Ctrl+C drains in-flight tasks; second Ctrl+C force-quits

Documentation

Quick Start Tutorial and API walkthrough
Technical Overview Architecture, serialization format, internals
Signing & Pairing Cryptographic task signing protocol
Sandbox Docker container isolation
Cloud POC Local FastAPI + MongoDB + Kubernetes + React prototype for managed hosting

Examples

offwork worker --backend local://localhost:9748 --tmp
offwork run examples/remote_execution.py

remote_execution.py · async_execution.py · package_installation.py · progress_reporting.py · cancellation.py · scheduling.py · throttling_and_retry.py · large_module.py

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.1.0.tar.gz (95.7 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.1.0-py3-none-any.whl (113.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for offwork-0.1.0.tar.gz
Algorithm Hash digest
SHA256 086c070a4dc7e799f2b71cb8fa5690cb067a86558c0055e4807920676a526dc7
MD5 8b5c10373845afafc059c768e7fb6d40
BLAKE2b-256 dbb8ead2fdd9a5f2af1faa1d86414c9d164bdb2c7fe5881f987ad7c2fde25f00

See more details on using hashes here.

File details

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

File metadata

  • Download URL: offwork-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 113.0 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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b377b3dc759ca7b2d37bda79366164a66cb8d76cde745af187c413b244ffea83
MD5 10219e70f7e8ed73f9760f335570be0c
BLAKE2b-256 30c68c05d17a7f873204a712fcd8731063e6f3e03f5662c07e84321abd1adcbd

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