FastWorker grows with your project. Start with one file and refactor as you scale.
When: Prototyping, small scripts, < 5 tasks.
project/
└── mytasks.py
# mytasks.py
from fastworker import task
@task
def add(x: int, y: int) -> int:
return x + y
@task
def greet(name: str) -> str:
return f"Hello, {name}!"fastworker control-plane --task-modules mytasks
fastworker submit --task-name add --args 5 3Everything in one file. fastworker discovers all @task-decorated functions automatically.
When: 5-15 tasks, multiple developers, tasks are getting hard to find.
project/
└── tasks/
├── __init__.py # re-exports everything
├── emails.py
└── reports.py
# tasks/__init__.py
from project.tasks.emails import * # noqa
from project.tasks.reports import * # noqafastworker control-plane --task-modules project.tasksThe __init__.py acts as a single import point. Add new task modules freely — just re-export them.
When: 15+ tasks, shared business logic, need separation of concerns.
project/
└── app/
├── tasks/
│ ├── __init__.py
│ ├── background.py # one-shot tasks
│ └── scheduled.py # periodic/cron tasks
├── services/
│ └── notifications.py # business logic
└── models/
└── schemas.py # pydantic models
Tasks are thin wrappers. Business logic lives in services/:
# app/tasks/background.py
from fastworker import task
from app.services.notifications import send_email
@task
def notify_user(user_id: int, message: str):
return send_email(user_id, message)fastworker control-plane --task-modules app.tasksWhen: Building a web API with background processing.
project/
└── app/
├── api/
│ └── routes.py # FastAPI endpoints
├── tasks/
│ ├── __init__.py
│ ├── background.py
│ └── scheduled.py
├── services/
├── models/
└── main.py # FastAPI app + FastWorker
# app/main.py
from fastapi import FastAPI
from fastworker.integration.fastapi import FastWorker
from app.api.routes import router
import app.tasks # registers @task functions
app = FastAPI()
app.include_router(router)
fw = FastWorker(app)# Terminal 1
fastworker control-plane --task-modules app.tasks
# Terminal 2
uvicorn app.main:app --reload| Signal | Action |
|---|---|
| Scrolling past 100 lines in one task file | Move to package |
| Copy-pasting logic between tasks | Extract to services/ |
| Need cron or periodic execution | Add scheduled.py |
| Building a web UI for your app | Add FastAPI integration |
| Tasks sharing database models | Create models/ directory |
fastworker list --tree --task-modules app.tasksShows the module hierarchy with task names and schedule metadata.