This is a demo for the talk Is Django async yet?.
A Docker Compose V2 file is provided to run the Postgresql database.
You can start the database with:
docker compose up
On another shell you can create the virtual environment and install the requirements:
python3 -m venv venv
. ./venv/bin/activate
pip install -r requirements.txt
This assumes the environment has been created and is activated.
You can start the async application with the following command:
cd demo
gunicorn demo:wsgi --workers 1 --bind 0.0.0.0:8000
The API will be available at http://localhost:8000.
This assumes the environment has been created and is activated.
You can start the async application with the following command:
cd ademo
gunicorn ademo.asgi:application --workers 1 --worker-class uvicorn.workers.UvicornWorker --bind 0.0.0.0:8080
The API will be available at http://localhost:8080.
If you want to debug asgiref.sync
sync_to_async
and async_to_sync
usage you can run the service using
OpenTelemetry automatic instrumentation:
opentelemetry-instrument --traces_exporter console --metrics_exporter none --service_name ademo \
gunicorn ademo.asgi:application --workers 1 --worker-class uvicorn.workers.UvicornWorker --bind 0.0.0.0:8080