Questions tagged [asgi]

ASGI stand for Asynchronous Server Gateway Interface (ASGI), a "spiritual successor to WSGI, intended to provide a standard interface between async-capable Python web servers, frameworks, and applications."

An ASGI app is a a double, asynchronous callable (scope and coroutine). The callable has send and receive awaitables, thus the ability to wait for incoming events and send outgoing events. Events essentially are dictionaries with a predefined format that form the basis of the standard.

Official ASGI documentation

212 questions
44
votes
1 answer

Django 3.x - which ASGI server (Uvicorn vs. Daphne)

I have a simple API-based web application written in Django 3. In the Django documentation there is a page about ASGI servers, and two options are mentioned: Daphne and Uvicorn. Unfortunately, they do not provide any description about the benefits…
rafaljusiak
  • 1,050
  • 1
  • 10
  • 17
39
votes
1 answer

Gunicorn gevent workers vs Uvicorn ASGI

I'm currently developing a service in Django which makes use of a slow external API (takes about 10s to get a response), which means the connections to my server are kept open waiting for the external API to respond, and occupying worker…
imricardoramos
  • 846
  • 1
  • 7
  • 12
27
votes
3 answers

Django daphne asgi: Django can only handle ASGI/HTTP connections, not websocket

This is really frustrating, I did set everything up according to the documentation, but daphne keeps throwing an error when I try to run it independently, it does work correctly when I use python manage.py run server. this is very frustrating and I…
SenseofDeath
  • 271
  • 1
  • 3
  • 5
20
votes
3 answers

Django apps aren't loaded yet when using asgi

I'm tring to run my django project with usage of asgi instead of wsgi. I have set up my routing.py and asgi.py as follows: routing.py from django.conf.urls import url from channels.routing import ProtocolTypeRouter, URLRouter from…
kebie
  • 485
  • 5
  • 16
19
votes
2 answers

Graceful shutdown of uvicorn starlette app with websockets

Given this sample Starlette app with an open websocket connection, how do you shut down the Starlette app? I am running on uvicorn. Whenever I press Ctrl+C the output is Waiting for background tasks to complete. which hangs forever. from…
Neil
  • 8,925
  • 10
  • 44
  • 49
18
votes
1 answer

TypeError: __call__() missing 1 required positional argument: 'send' Django

When I run the project through the gunicorn (command: gunicorn --bind :8000 myproject.asgi:application), I get this error. Error Traceback (most recent call last): File "/venv/lib/python3.8/site-packages/gunicorn/workers/sync.py", line 136, in…
Sultan Syidaliev
  • 181
  • 1
  • 1
  • 3
13
votes
10 answers

uvicorn is not working when called from the terminal

I tried installing uvicorn on the system via pip3 which worked, however i am unable to run the same from the command line. Any pointers as to how to resolve this? Requirement already satisfied: uvicorn in…
varun krishna
  • 173
  • 1
  • 2
  • 9
11
votes
1 answer

How to run Windows IIS on top of an ASGI server like hypercorn or uvicorn?

I have an api based web application written in python using FastApi which uses Uvicorn or Hypercorn for deployment.These both are ASGI based servers. Is there a way to run IIS on top of this ?
Lak Hinsu
  • 111
  • 1
  • 4
11
votes
5 answers

ValueError: set_wakeup_fd only works in main thread on Windows on Python 3.8 with Django 3.0.2 or Flask 2.0.0

When I run my Django Web application with Apache2.4.41 + Python 3.8.1 + Django 3.0.2 + MySQL 8.0.19 on Windows 10 Professional version it throws Value Error at /. set_wakeup_fd only works in main thread. This issue was a result of regression in…
Siddharth Agarwal
  • 158
  • 1
  • 2
  • 9
10
votes
1 answer

Uvicorn async workers are still working synchronously

Question in short I have migrated my project from Django 2.2 to Django 3.2, and now I want to start using the possibility for asynchronous views. I have created an async view, setup asgi configuration, and run gunicorn with a Uvicorn worker. When…
physicalattraction
  • 6,485
  • 10
  • 63
  • 122
10
votes
3 answers

migrating flask web application currently using uWSGI web server to ASGI web server(uvicorn)

I currently have a flask web application using uWSGI web server that implements the WSGI standard and need to migrate this app to uvicorn web server that implements the ASGI standard. If I choose to use uvicorn web server from the many available…
Khushboo Mulani
  • 389
  • 1
  • 3
  • 10
8
votes
2 answers

FastApi: How to define a global variable once

I want to define a dict variable once, generated from a text file, and use it to answer to API requests. This variable should be always available till the end of server run. In an example below: from fastapi import FastAPI import uvicorn app =…
8
votes
1 answer

How to configure Daphne proxy with Nginx and uwsgi

I have a Django application located in a server with Nginx and uwsgi configuration. And now I have to work with Django Channels too. In a local computer all it's fine but I have read a lot about that Django Channels is not compatible with uwsgi. I…
8
votes
2 answers

How to generate asgi.py for existent project?

I have an existent django project in 2.2, but now i would like to start using channels, so I have to change to 3.0 and asgi instead of wsgi. How can I generate the asgi.py that I need to run the app?
Xhark
  • 781
  • 1
  • 9
  • 24
7
votes
1 answer

Uvicorn backlog vs limit-concurrency

I'm trying to understand the interaction between the "backlog" flag, and the "limit-concurrency" flag of uvicorn. From the documentation(https://www.uvicorn.org/settings/) Backlog: Maximum number of connections to hold in backlog. Relevant for heavy…
Cruncher
  • 7,641
  • 1
  • 31
  • 65
1
2 3
14 15