This repository is here to reproduce a bug observed in the usage of background tasks in Starlette.
Install uvicorn, gunicorn and starlette
pip install uvicorn gunicorn starlette
Launch the server either with uvicorn
, on a TCP or Unix socket:
uvicorn bg_tasks:application --port 8000
uvicorn bg_tasks:application --uds server.sock
Or with gunicorn
gunicorn -k uvicorn.workers.UvicornWorker bg_tasks:application --bind 127.0.0.1:8000
gunicorn -k uvicorn.workers.UvicornWorker bg_tasks:application --bind unix:server.sock
The HTTP client scripts will target port 8000 (default for both uvicorn and gunicorn).
To call the /single
route - connection is closed after response is received:
python http_call.py single --tcp 127.0.0.1:8000
python http_call.py single --uds server.sock
To call the /multiple
route - connection is closed after response is received:
python http_call.py multiple --tcp 127.0.0.1:8000
python http_call.py multiple --uds server.sock
To call the /wait
route and close connection without waiting for the response:
python http_call.py wait --tcp 127.0.0.1:8000 --action close_nowait
python http_call.py wait --uds server.sock --action close_nowait