Compact guidance for OpenCode sessions working in this repo. Read CONTRIBUTING.md and .github/agents/superjoe.agent.md for the full conventions.
Queue-agnostic worker pool for Django's task framework. Targets Django 6.1 (alpha/dev) and Python >=3.12. Package: threadmill/. Tests: tests/ with a Django test app at tests/testapp/.
All commands run via uv:
uv run pytest # full suite (incl. benchmarks, coverage)
uv run pytest -m "not benchmark" # what CI runs by default
uv run pytest -m integration # integration tests only
uv run pytest -m "integration and benchmark"
uv run pytest --benchmark-compare # compare vs main baseline (run main first)
uvx prek run --all-files
uv run manage.py threadmill worker # run the worker pool
uv run manage.py threadmill inspector # launch the textual TUI inspectorCI additionally pins Django per matrix step: uv run --with django~=6.1a1 pytest -m "not benchmark".
Run a single test by node ID, e.g. uv run pytest tests/test_command.py::TestCommand::test_add_arguments__register_all_worker_options.
- Install pre-commit hooks before first commit:
uvx prek install(notpre-commit install). DJANGO_SETTINGS_MODULE=tests.testapp.settingsis already set in.envand inpyproject.toml. Pytest auto-loads it.- CI's Linux job starts a Redis service and sets
REDIS_URL; some integration tests may rely on it. Local runs of-m integrationmay need Redis if a backend test targets it.
- Follow the
naming-thingsguidelines — fetch at session start:curl -sSL https://raw.githubusercontent.com/codingjoe/naming-things/refs/heads/main/README.md
- Use Google-style docstrings for mkdocs. NEVER use RST directives (
:param:,:returns:,:meth:). - NEVER format code, tests, or docs manually. MUST USE
prek run --all-files.
Codecov requires 100% patch coverage on PRs (pyproject.toml, .codecov.yml). New code must be fully tested; remove unreachable branches rather than excluding them.
threadmill/_version.pyis written bysetuptools_scmfrom git tags.uv.lock,.coverage,coverage.xml,.benchmarks/are build/test artifacts.
- Entry point for end users:
threadmill/management/commands/threadmill.py(Django management command withworkerandinspectorsubcommands). - Core runtime:
threadmill/executor.py(TaskExecutor) — process/thread pool, graceful shutdown, worker recycling, task timeout/backlog. - Integration point for queue authors:
threadmill/backends.py(AcknowledgeableTaskBackend) — subclasses implementacquire(lock-without-remove) andacknowledge(remove + publish). Requires late-ack support from the underlying queue. - Test app backend
tests/testapp/backends.py(GeneratingTaskBackend) generates tasks in-process for benchmarks; reset between runs viadefault_task_backend.reset().
.pre-commit-config.yaml runs ruff (check + format), django-upgrade, pyupgrade, mdformat (excludes .github/agents/), yamlfmt, and no-commit-to-branch (protects main). Hooks auto-fix; ruff is configured --exit-non-zero-on-fix, so commit any fixes before pushing.
CI runs on main pushes and PRs. Releases are published to PyPI via .github/workflows/release.yml on GitHub release. Commits to main are blocked by no-commit-to-branch; work on a branch.