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

How to set up gunicorn and uvicorn with nginx and django chanels?

I am stuck at this problem and I need help. I am trying to configure nginx server with django-channels and I have the following configurations, Nginx: server { server_name {{ my_domain }}; location = /favicon.ico {access_log…
Mindru Ion
  • 373
  • 5
  • 19
2
votes
2 answers

Starlette + asyncio.create_task() doesn't log error if task object is stored in instance variable

Okay, this is very weird, but here goes - import asyncio from starlette.applications import Starlette class MyTasks: def __init__(self): self.task = None async def main(self): self.task =…
Dev Aggarwal
  • 7,627
  • 3
  • 38
  • 50
2
votes
0 answers

How to configure synchronous SQLAlchemy ORM use in an ASGI app?

I am attempting to configure an ASGI application whose data layer relies on SQLAlchemy ORM. I know that it's possible to use Core completely asynchronously with something like databases or GINO. However, our server architecture is such that database…
One Crayon
  • 19,119
  • 11
  • 33
  • 40
2
votes
1 answer

Can Quart (the ASGI Flask alternative) be proxied through nginx?

I currently have a Flask app proxied behind Nginx via uWSGI. Due to my needs for asyncio and websockets, I would prefer to switch to Quart. I use nginx to manage authentication and performantly/simply serve static files. It would be nice to keep…
trbabb
  • 1,894
  • 18
  • 35
2
votes
1 answer

How to add gzip compression to Hypercorn server serving a Quart app

I have a quart app running on a hypercorn (0.6) server. (EC-2 amazon Ubuntu 18) The page loads too slow and one of the recommendations is to add gzip compression. Does anyone have experience with this? kind regards, alex
socialb
  • 135
  • 1
  • 9
2
votes
1 answer

How to read from (hdf5) file in async contexts?

Lately I've been playing around a little with the python 3 async features. Overal I'm quit happy with the 3.6 syntax and of course the performance boost you gain. One of the exciting projects evolving around the ASGI standard in my opinion is…
LarsVegas
  • 6,522
  • 10
  • 43
  • 67
1
vote
1 answer

How to use django asynhronous programming with drf API views?

I am trying to implement asynchronous programming with django rest framework and I am using api_view decorators for my function based API views. So I was trying to convert my synchronous method to asynchronous with asgiref.sync.sync_to_async…
1
vote
1 answer

How can I fix the error of not being able to establish a connection to a Django Channels server with WebSockets using Python and ASGI?

Django channels & websockets : can’t establish a connection to the server. I am trying to do a real-time drawing app using django channels, websockets & p5. The only problem I've got is : Firefox can’t establish a connection to the server at…
antaww
  • 55
  • 6
1
vote
0 answers

DRF asgi request don't have request.data

class HelloWorldView(APIView): def post(self, request): print("request body....", request._request.body) print(f"drf data {request.data}") print("inside request type...", type(request._request)) return HttpResponse("Hello…
Sandeep Balagopal
  • 1,943
  • 18
  • 28
1
vote
1 answer

How can my python program do work and serve results via FastAPI at the same time?

I have a Python program that reads financial market data to do some analysis. I want to offer the results of the analysis via FastAPI. The problem is that when I start the uvicorn server for fastAPI, the rest of my Python program, especially the…
1
vote
0 answers

Django channels, UserWarning: async_to_sync was passed a non-async-marked callable

I am using Django channels for the notification system,i want to send a notification to the associated store when an order is created, i create Notification model to save all previous notifications and in my post_save order signal i create…
1
vote
0 answers

FastAPI, ASGI middleware, sync routes & thread-local data

I've been migrating an existing WSGI app to FastAPI. I'm having trouble fully understanding the different dynamics of the two frameworks, and hope you can shed some light conceptually. At the moment I have the following setup, largely inspired by…
expatriate
  • 41
  • 4
1
vote
0 answers

Channels Websocket automatic close after one message

I'm developing a Django based web server which integrates a websocket for data visualizations in real time (my web server reads values from a PLC via OPCUA and displays them in real time on a web page). The server works correctly in development mode…
Nikyde
  • 11
  • 1
1
vote
1 answer

Is having a concurrent.futures.ThreadPoolExecutor call dangerous in a FastAPI endpoint?

I have the following test code: import concurrent.futures import urllib.request URLS = ['http://www.foxnews.com/', 'http://www.cnn.com/', 'http://europe.wsj.com/', 'http://www.bbc.co.uk/', …
reza
  • 5,972
  • 15
  • 84
  • 126
1
vote
2 answers

FastAPI is not quitting when pressing Ctr+c

I am finding a difficulty with quitting FastAPI. Ctr+c does not work. Here is my pyproject.toml [tool.pyright] exclude = ["app/worker"] ignore = ["app/worker"] [tool.poetry] name = "api" version = "0.1.0" description = "" authors = ["SamiAlsubhi…
Sami Al-Subhi
  • 4,406
  • 9
  • 39
  • 66