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
5
votes
0 answers

Django Channels "took too long to shut down and was killed"

I am using Django Channels for a real-time progress bar. With the help of this progressbar the client gets actual feedback of a simulation. This simulation can take longer than 5 minutes depending on the data size. Now to the problem. The client can…
Dennis
  • 51
  • 3
5
votes
1 answer

Run multiple asgi apps in same thread with uvicorn

I want to run a starlette and django app in the same thread. (Having them in same thread allows fast thread-local communication between them). Considering that asgi apps are just coroutines, I thought this should be theoretically possible with…
Dev Aggarwal
  • 7,627
  • 3
  • 38
  • 50
4
votes
1 answer

Users erratically getting CancelledError with Django ASGI

Our users are erratically getting CancelledError for any page in our system. The only pattern we’ve observed is that this happens more often for pages which take more time to load during normal operation. But it is absolutely not limited to such…
4
votes
1 answer

How to use the power of uvicorn and asgi in django?

I implemented a tiny Django app (v4.0.4) containing a REST API — GET method for retrieving some data. Next, I wanted to run the project using gunicorn+uvicorn since I saw a more benchmark performance than a normal deployment in an article. So I…
Benyamin Jafari
  • 27,880
  • 26
  • 135
  • 150
4
votes
0 answers

After Nginx Unit, Do we still need ASGI like Uvicorn, Hypercorn, Daphne etc

I checked NGINX Unit documentation for deploying FastAPI and Django Channels. They did not use any ASGI like Uvicorn, Hypercorn, Daphne. Their configuration page also did not mention anything about using these servers. Updates to NGINX Unit for…
Ahmad Ismail
  • 11,636
  • 6
  • 52
  • 87
4
votes
2 answers

Running django with ASGI?

I have a django app I using this [docker] (https://github.com/tiangolo/uvicorn-gunicorn-docker) for production deployment when I run the app using: gunicorn --log-level debug --workers 3 myapp.asgi:application --worker-class…
helpper
  • 2,058
  • 4
  • 13
  • 32
4
votes
3 answers

Count number of requests with global variable using FastAPI

I want to count the number of requests in a specific URL path. app = FastAPI() counter = 0 @app.get("/do_something") async def do_something(): global counter counter += 1 return {"message": "Hello World"} Is this code ok? The counter…
idan ahal
  • 707
  • 8
  • 21
4
votes
0 answers

FastApi is not running every request on same endpoint in separate Thread

So, I think I understand all async def and def stuff. I have this piece of code and I am running it with uvicorn main:app import time from fastapi import FastAPI app = FastAPI() @app.get("/") def root(): print("Hitted Root") …
Nilan Saha
  • 191
  • 1
  • 9
4
votes
1 answer

fastapi could not find model defintion when run with uvicorn

I want to host a pytorch model in a fastapi backend. When I run the code with python it is working fine. the depickled model can use the defined class. When the same file is started with uvicorn it cannot find the class definition. Sourcecode looks…
4
votes
1 answer

Do I need to change my normal Django code when introducing Django Channels?

Hello I am a beginner in the python world, so I am still trying to understand the care when working with ASGI. I read some tutorials and documentation, as well as watched some videos on youtube. However, I was unsure on some points. I have a small…
Marlon Patrick
  • 2,366
  • 1
  • 18
  • 26
4
votes
2 answers

Django graphene GraphiQL page not loading when running from Uvicorn

Not sure what I set wrong but I am not getting the graphiql interface when running in uvicorn using uvicorn mysite.asgi:application: [32mINFO[0m: Started server process [[36m14872[0m] [32mINFO[0m: Waiting for application…
ccsv
  • 8,188
  • 12
  • 53
  • 97
4
votes
1 answer

Problem in running ASGI environments while deploying app Django Rest

I am developing an app using Django,I have deployed it on Google Cloud Platform initially using WSGI environment,now I have made addition in app and used channels due to which I have to shift from WSGI to ASGI, but I am getting errors while…
Nabeel Ayub
  • 1,060
  • 3
  • 15
  • 35
3
votes
1 answer

how to deploy fastapi app on shared hosting using wsgi server?

in a recent article, https://www.vultr.com/docs/how-to-deploy-fastapi-applications-with-gunicorn-and-nginx-on-ubuntu-20-04/ I read that fastapi "can work with WSGI if needed". I was wondering how? I did a whole project with fastapi and tried to…
3
votes
0 answers

Django Channels AsyncWebSocketConsumer ConnectionClosedError 1005

I am writing a django channels application and noticed an exception when handling a heartbeat function related to websocket status code which I haven't been able to find any existing issues for. This is in an AsyncWebsocketConsumer backed by…
BillPull
  • 6,853
  • 15
  • 60
  • 99
3
votes
0 answers

FastAPI app still process the request though the connection has been disconnected from the client end

I have a FastAPI app that runs on Gunicorn Webserver and the gateway interface is ASGI. I try to simulate a response that takes a long time in my FastAPI App, and I expect that when I disconnect from the request connection currently under processing…
Dayo Choul
  • 861
  • 2
  • 9
  • 23
1 2
3
14 15