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 inverse(x: float) -> float:
return 1 / x
@offwork.task # only the entry point needs this - inverse() is captured automatically
def inverse_root(n: float) -> float:
return inverse(math.sqrt(n))
async def main():
print(await inverse_root.run(4)) # 0.5
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:
# Worker
pip install offwork[redis]
offwork worker --backend redis://redis-service.svc:6379
# Client
offwork.connect("redis://redis-service.svc:6379")
Features
| Async-native | .run(), .submit(), .map(), asyncio.gather — all coroutines |
| Streaming | async def ... yield tasks; consume with async for v in task.stream(...) — event-driven, no polling |
| 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
Metadata
Release files for offwork 0.2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| offwork-0.2.3.tar.gz | 119.2 kB | Without provenance | Details for offwork-0.2.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| offwork-0.2.3-py3-none-any.whl | Python 3 | none | any | Details for offwork-0.2.3-py3-none-any.whl |
Total release size: 260.4 kB
Release files / offwork-0.2.3.tar.gz
| Download URL | offwork-0.2.3.tar.gz |
|---|---|
| Size | 119.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
06a2e55c7946d36f76831cfe9d9aedfd11a82eb4d6e5a49dc313e943c6191412
|
|
BLAKE2b-256 checksum How to use checksums |
0292c06d0c4880cc92292e945472d16842bc156026e60cb6a86c1c2fefe79657
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.9
|
Release files / offwork-0.2.3-py3-none-any.whl
| Download URL | offwork-0.2.3-py3-none-any.whl |
|---|---|
| Size | 141.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
600b78114d9e9743670c6230c0b188f429a576e6db5389d7d5ac3970766239a7
|
|
BLAKE2b-256 checksum How to use checksums |
641e46fd5b451409121a480404e9c5f285c626f42f2606defa990c0c3dec00e0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.9
|
Security for offwork 0.2.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.