Skip to main content

Distributed Python task execution via automatic function serialization

Reason this release was yanked:

Tests don't pass

Project description

offwork

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

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

Add @offwork.task to a function. offwork captures its source, all dependencies, and all 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
import offwork

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

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

@offwork.task
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 @offwork.task — 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.

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 @offwork.task(timeout=30, retries=3) with exponential backoff
Scheduling .run_in(delay), .run_at(datetime), .run_every(freq) with cancellation
Throttling @offwork.task(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:// (TCP), redis://, amqp:// (RabbitMQ), https:// (hosted)
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

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.

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
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.

Documentation

Quick Start Tutorial 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
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.1.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.1-py3-none-any.whl (113.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: offwork-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 139ec17dbc77d86857c2d2ff21d7f4f38d39b2708edeaf94ffc6c9e4431aaec4
MD5 cd6880d3bc76ee3100ecc8475bca9b22
BLAKE2b-256 81ecc73727f6ceb33b0c0ea219ec797a96a19523bdb8a0a31d5f5cb9a3df5d98

See more details on using hashes here.

File details

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

File metadata

  • Download URL: offwork-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 113.1 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 226ff4ab61851750b77f9f658b4e5715396d1f0d63e9dce335c188e3e5b1e01b
MD5 c2e8e9ae4d0f3609b0a9ae4c57fef4b3
BLAKE2b-256 6ba0fc4ce9e2d8e3e1c7ac892e003c0499af67eeb1bf19267f947625a523cdb2

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