๐Ÿ“ฆ xrmx / isdjangoasyncyet-demo

โ˜… 2 stars โ‘‚ 0 forks ๐Ÿ‘ 2 watching โš–๏ธ MIT License
๐Ÿ“ฅ Clone https://github.com/xrmx/isdjangoasyncyet-demo.git
HTTPS git clone https://github.com/xrmx/isdjangoasyncyet-demo.git
SSH git clone git@github.com:xrmx/isdjangoasyncyet-demo.git
CLI gh repo clone xrmx/isdjangoasyncyet-demo
Riccardo Magliocchetti Riccardo Magliocchetti README: Add missing backtick 8a3b302 1 years ago ๐Ÿ“ History
๐Ÿ“‚ main View all commits โ†’
๐Ÿ“ ademo
๐Ÿ“ demo
๐Ÿ“„ .gitignore
๐Ÿ“„ compose.yml
๐Ÿ“„ LICENSE
๐Ÿ“„ README.md
๐Ÿ“„ requirements.txt
๐Ÿ“„ README.md

isdjangoasyncyet-demo

This is a demo for the talk Is Django async yet?.

Requirements

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

How to run the sync demo

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.

How to run the async demo

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.

OpenTelemetry instrumentation

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