Distributed Python task execution via automatic function serialization
Project description
offwork
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
See Features for the full API.
Features
| Async-native | .run(), .start(), .map(), asyncio.gather — all coroutines |
| Scheduling | .run_in(delay), .run_at(datetime), .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; await future.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 |
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file offwork-0.1.3.tar.gz.
File metadata
- Download URL: offwork-0.1.3.tar.gz
- Upload date:
- Size: 102.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
64e32b1bb5d96763ce763d71b36e13d16e0cddf82e2ae254cb2c38f71ddcda02
|
|
| MD5 |
c2e7b2acfe3c4133916e98638a292800
|
|
| BLAKE2b-256 |
963ecb6e4fc1270a646825e59a39d0824fd2b46e1b777eb2a8dfbd1544ec1d6d
|
File details
Details for the file offwork-0.1.3-py3-none-any.whl.
File metadata
- Download URL: offwork-0.1.3-py3-none-any.whl
- Upload date:
- Size: 122.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3c8c3189c09213bd9cde196de6f9d1df822921559eb41773f49588ec5d4055ba
|
|
| MD5 |
ec5b590d2d8a649f3b6fc68953536022
|
|
| BLAKE2b-256 |
2d7f965e850160f8697b707fd2a5d4ad6224f5d0843262a89100dc6851e03d96
|