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

111 questions
18
votes
3 answers

Architecture Flask vs FastAPI

I have been tinkering around Flask and FastAPI to see how it acts as a server. One of the main things that I would like to know is how Flask and FastAPI deal with multiple request from multiple clients. Especially when the code has efficiency issues…
Justin Yeoh
  • 185
  • 2
  • 6
18
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
  • 604
  • 4
  • 12
17
votes
2 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
  • 171
  • 1
  • 5
13
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
  • 497
  • 3
  • 14
11
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
  • 7,565
  • 8
  • 38
  • 48
7
votes
1 answer

`NameError: name 'TypeError' is not defined` in Apache (mod_wsgi)

Install Version Apache apr-1.6.5 apr-util-1.6.1 httpd-2.4.7 mod_wsgi-4.6.8 pcre-8.32 Python 3.8.5 Django 3.1.2 Apache http.conf Listen 3600 WSGISocketPrefix /var/run/wsgi WSGIDaemonProcess project_name…
이경언
  • 146
  • 10
7
votes
0 answers

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
  • 71
  • 2
7
votes
0 answers

What is the different in Django 3 ASGI and Django 2 + Channels?

django-channels is on my 1st list of material I am going to learn during this new year. But Django 3 also has ASGI feature without any document on it. Then I doubt that what is the different between django-channels use cases VS Django 3 ASGI?
joe
  • 5,158
  • 8
  • 38
  • 79
7
votes
3 answers

Python asyncio skip processing untill function return

I'm still very confused about how asyncio works, so I was trying to set a simple example but couldn't achieve it. The following example is a web server (Quart) that receives a request to generate a large PDF, the server then returns a response…
Mojimi
  • 1,651
  • 5
  • 30
  • 81
6
votes
4 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…
6
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
  • 315
  • 2
  • 13
5
votes
1 answer

What's the right procfile / requirements for heroku with django channels?

tl;dr - django channels app runs local with manage.py runserver but not on heroku. I'm new to django channels - trying to deploy a very basic django app using channels to heroku. I initially built the project using the standard django polls…
Krishna
  • 51
  • 2
5
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
  • 161
  • 2
  • 7
5
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
  • 589
  • 5
  • 19
5
votes
2 answers

Django 3.0 + Channels + ASGI + TokenAuthMiddleware

I upgraded to Django 3.0 and now I get this error when using websockets + TokenAuthMiddleware: SynchronousOnlyOperation You cannot call this from an async context - use a thread or sync_to_async.
Max Malysh
  • 21,876
  • 16
  • 91
  • 102
1
2 3 4 5 6 7 8