Examples
Runnable mini example apps live in the
examples/
directory of the repository, each with its own README.md with run
instructions. They are also covered by a smoke test in the test suite, so
they are guaranteed to keep working.
- Plain Python -- no web framework at all, the same producer/worker split as the tutorial.
- Async plain Python -- the same split again, but
built on
AsyncAlchemicalQueues/AsyncWorkerinstead of their sync equivalents. - FastAPI -- schedules a task per request, result serialized
as a pydantic model. Also built on
AsyncAlchemicalQueues/AsyncWorker, running the worker as a plainasynciotask on the app's own event loop. - Flask -- schedules a task per request, result serialized as
JSON. See also the Flask-SQLAlchemy example
for sharing an engine with
flask_sqlalchemy. - Starlette -- the same pattern as FastAPI on plain ASGI, with the default pickle serializer.
- Litestar -- the same pattern again on Litestar.
All of them use alchemical_queues.tasks.
FastAPI is the only one on the async core/worker so far; Flask, Starlette
and Litestar run their (sync) worker in a background thread inside the web
process purely to keep the example to a single command -- see each
example's README for why you would normally run alchemical_worker (or,
for the async examples, your own worker script) as a separate process
instead.