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

Django async view - how do I know its running async?

I can create an async view and inquire as to whether the method thinks it's a coroutine, and it is. However, looking at the stack it looks like my view is being called by asgiref's AsyncToSync. I am using Gunicorn with Uvicorn worker and an asgi.py…
LiteWait
  • 584
  • 4
  • 21
  • 42
0
votes
0 answers

how to run tasks in parallel with django async

i'm using daphne as a asgi server, with django. turning my view from sync to async was relatively simple, since i could use @sync_to_async at the ORM part. the problem is, some service of mine is like this: async def service_of_mine(p1, p2, p3): …
rado
  • 5,720
  • 5
  • 29
  • 51
0
votes
0 answers

How to divide Daphne requests on mutiple processors?

I use a Daphne server for my ASGI Django application. When I run htop on my Ubuntu server it shows all the load on only one processor and the app gets slow, so I'd like to know what is the easiest way to speed up my server. App is inside a Docker…
0
votes
0 answers

how to split requests between uwsgi and asgi servers with nginx

i had this configuration: upstream my_custom_upstream { server container-1:8000 weight=99; server container-2:8001 weight=1; } location = /my_url { uwsgi_pass my_custom_upstream; ... } now i'm changing only container-2 to run on…
rado
  • 5,720
  • 5
  • 29
  • 51
0
votes
0 answers

Hypercorn config server_names

I've got some REST API's working with FastAPI and Hypercorn. Now I'm configuring hypercorn with logging, https, etc... but I'm having some trouble with the server_names option. Trying to make it so that only my computer can get the results from the…
Carlos
  • 21
  • 4
0
votes
1 answer

Django application with ASGI Uvicorn increasing the latencies by 4x

We are using a Django application (https://github.com/saleor/saleor) to handle our e-commerce use-cases. We are using ASGI with Uvicorn in production with 4 workers. Infra setup - 4 instances of 4 core 16 GB machines for hosting the Django…
Gaurav Raj
  • 699
  • 6
  • 21
0
votes
1 answer

Is it posible to listen to an MQTT server and publish with Websocket (endpoint) from our own server

I have got an mqtt consumer that listens to a topic and based on that, I used to send a response on another topic. However now I would like to create a Websocket Secure wss endpoint where i could stream this processed information. Could you tell me…
Jonathan Prieto
  • 233
  • 4
  • 14
0
votes
1 answer

Django + GUnicorn ASGI with SCRIPT_NAME

I have a Django application running with a gunicorn ASGI server and an NGINX reverse proxy for serving static content. All are packaged within a docker container. Now I want to serve this container behind a reverse proxy with a path prefix, e.g.…
mrdlink
  • 266
  • 4
  • 15
0
votes
1 answer

Why do I get errors when starting Daphne for prod / IIS?

I'm using Django eventstream for SSE and Channels (I'm not able to use Memurai or Redis). When I run the local server, everything works great. The user can submit a file, that information is ran against the external 3rd party API it calls, and real…
ky922
  • 51
  • 7
0
votes
1 answer

How stream a response from a Twisted server?

Issue My problem is that I can't write a server that streams the response that my application sends back. The response are not retrieved chunk by chunk, but from a single block when the iterator has finished iterating. Approach When I write the…
florianvazelle
  • 141
  • 1
  • 7
0
votes
1 answer

How i can use "database_sync_to_async" function for fetching multiple object

I am implementing a consumer, and y want get all productos for example: class MyConsumer(AsyncConsumer): async def get_all_producs(): products = await database_sync_to_async(Products.objects.all)() When i try fetch all products from the…
0
votes
1 answer

How to allow a Channels consumer to access session generated by HTTP requests?

I have a project that used to run under WSGI, and I recently configured it to ASGI. It included code from back then, such as the following function that processes a login request: def authenticate(req): ... try: query =…
0
votes
0 answers

Don't start a thread in ASGI django while in manage.py

I am using Django 4.0.1 with the channels extension, so I'm using the ASGI interface. In one of my applications, I'm using it's AppConfig.ready() method to start a thread / asnyc loop - specifically the paho.mqtt package via loop_start(). If a…
Lars
  • 5,757
  • 4
  • 25
  • 55
0
votes
0 answers

How to implement SocketIO in Django ASGI

I tried this; https://github.com/ly3too/django-channels-with-socket.io But I keep getting 404 for the socket-io. Are there any other methods to implement the socket io?
A. Kruk
  • 1
  • 2
0
votes
0 answers

Azure Hosted ASGI Django Server Bottleneck When Handling Over a Dozen Simultaneous Requests

I'm new to working with ASGI and I'm having some performance issues with my Django API server so any insight would be greatly appreciated. After running some load tests using JMeter it seems that the application is able to handle under 10 or so…