Skip to main content

Distributed Python task execution via automatic function serialization

Reason this release was yanked:

Inherited version from pre-rebrand history; replaced by 0.1.0 as the proper first release.

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.4.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.4.0-py3-none-any.whl (113.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: offwork-0.4.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.4.0.tar.gz
Algorithm Hash digest
SHA256 19982787b18dad599f782e7720b96c357f4d2179b1aa52125a31421796f9bc00
MD5 3be3d9e3377749a1ee844a735e7d72c3
BLAKE2b-256 f67f829143f2de4750ba5a61b8d750fa37e907ea5be3f2a4fd5d27b2cf57615c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: offwork-0.4.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.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 735f6f6969fd14a1ea10d158714a7d1dda805c3b902ffc87c656316437d37d24
MD5 90afaecf416be7ca48c9133ca0d42de3
BLAKE2b-256 82c68075b3a0d8dec0d5d95f38f7670b66148469af5dcae4f5f22c9a283d49c6

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