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
1
vote
1 answer

django channels and running event loop

For a game website, I want a player to contest either agains a human or an AI. I am using Django + Channels (Django-4.0.2 asgiref-3.5.0 channels-3.0.4) This is a long way of learning... Human vs Human: the game take place is the web browser turn by…
FTG
  • 65
  • 1
  • 6
1
vote
1 answer

django channel issue during deployment

I am using Django Channels and deployed with NGINX+Gunicorn+Uvicorn and following the tutorial from Digital Ocean (i.e.…
Adi Putra
  • 35
  • 8
1
vote
0 answers

Django ASGI and WSGI Deploying Together

The application I developed using Django includes WSGI and ASGI applications together. What kind of way do I need to follow while deploying this application? In general, when I searched on the internet, I could not find anythig that deployed WSGI…
1
vote
1 answer

Django 3.2 `get_asgi_application` is not a replacement for channels AsgiHandler

TL;DR After an upgrade to Django 3.2, using the Channels deprecated method for ASGI handling works. Using the new recommended method doesn't work. I'm upgrading from Django 3.0/Channels 2 to Django 3.2/Channels 3. In channels 3.0 release notes, it…
edthrn
  • 1,052
  • 12
  • 17
1
vote
1 answer

Deploying JustPy to Heroku

I'm trying to deploy a JustPy app on Heroku. I'm new to both. Base code, from https://justpy.io/tutorial/getting_started/ # saved as app.py import justpy as jp app = jp.app # added for deployment def hello_world(): wp = jp.WebPage() …
Roger
  • 70
  • 1
  • 9
1
vote
2 answers

ASGI callable returned without starting response

The fastAPI that I am working on does not return traceback whenever the request failed, instead, it returns 500 Internal Server Error with error : ERROR: ASGI callable returned without starting response. 2021-05-14 16:12:08 - uvicorn.error:409 -…
Serena Xu
  • 219
  • 5
  • 10
1
vote
0 answers

RTSP wrapped with Content-Type: image/jpeg in StreamingHttpResponse

Was trying to wrap RSTP stream in StreamingHttpResponse and same is working completely fine with WSGI server in Django but i need to implement this with ASGI app. Below code for reference. In ASGI it continuously loading due to while True loop but…
1
vote
0 answers

django.core.exceptions.SynchronousOnlyOperation: You cannot call this from an async context - use a thread or sync_to_async

This is my asgi.py: """ ASGI config for VirtualLab_Server project. It exposes the ASGI callable as a module-level variable named ``application``. For more information on this file,…
Marian
  • 11
  • 2
1
vote
1 answer

Cannot use sync_to_async decorator after raising asyncio.CancelledError

import asyncio from asgiref.sync import sync_to_async @sync_to_async def sync_func(): print("sync_func() was CALLED (good!)") async def async_func(): print("async_func() was CALLED (good!)") async def test(excep_type: type =…
Silversonic
  • 1,289
  • 2
  • 11
  • 26
1
vote
0 answers

Django app: Heroku app crashes after switching to daphne

I was having a lot of issues getting websockets working for a chat app I'm building in Django on Heroku. Most of the stackoverflow posts use daphne instead of gunicorn in their Procfile, so I recently switched to using daphne. First question: Does…
Tom
  • 364
  • 2
  • 19
1
vote
1 answer

Messages not getting to consumer unless Heroku dyno count is scaled way up

We have built a front-end with React and a back-end with Django Rest Frameworks and channels. We are using Heroku Redis as our Redis provider. Our users connect to Channels via a ReconnectingWebSocket. We are using Python 3.6 and Channels 2.4 The…
JayBee
  • 540
  • 1
  • 5
  • 22
1
vote
0 answers

how to manage websocket connection in django use asgi

my application like this # asgi.py import os from django.core.asgi import get_asgi_application from websocket_app.websocket import websocket_application os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'websocket_app.settings') django_application…
pppppu
  • 33
  • 3
1
vote
0 answers

Logging with django channels using thread local storage problem

I am having issues with debugging multiple requests going through same piece of code, so there is a need of context information. And using this stackoverflow's answer Django logging with user/ip Logging each request with a unique request_id, able to…
A100
  • 11
  • 1
  • 5
1
vote
2 answers

How do I manage asynchronous startup and shutdown of resources in a Tornado application?

I'd like to use aioredis in a Tornado application. However, I couldn't figure out a way to implement an async startup and shutdown of its resources since the Application class has no ASGI Lifespan events such as in Quart or FastAPI. In other words,…
andref
  • 750
  • 5
  • 20
1
vote
2 answers

Django Channels consumer consuming 1 call twice

I am using a combination of DRF 3.11.0 and Channels 2.4.0 to implement a backend, and it is hosted on Heroku on 1 dyno with a Redis resource attached. I have a socket on my React frontend that successfully sends/received from the backend server. I…
JayBee
  • 540
  • 1
  • 5
  • 22