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

Problem with ASGI lifespan when using middleware in fastAPI

These are the files which I'm using in my project main.py from fastapi import Depends, FastAPI from mysqlx import Session from database import test_db_connection from utils import get_db, login_user from schemas import UserLogin from…
0
votes
1 answer

asgiref.sync_to_async doesn't propagates inner exceptions properly

When using sync_to_async inside an async block (like the following code), the exception is printed only on exit (after 10 seconds, when loop is shutting down) import asyncio from asgiref.sync import sync_to_async def f(): 1 / 0 async def…
Taha Jahangir
  • 4,774
  • 2
  • 42
  • 49
0
votes
1 answer

How to change/suppress server header with gunicorn and uvicorn worker class?

I'm running my python asgi application with gunicorn and uvicorn worker class with this command line: unicorn -c gunicorn_conf.py my.asgi:application -k uvicorn.workers.UvicornWorker I want to obfuscate the server HTTP header. The uvicorn…
sgargel
  • 986
  • 2
  • 11
  • 29
0
votes
0 answers

How to find out what WSGI server is used in a shared host

I have a shared host with LiteSpeed server. After messing around with cPanel, I found out Phusion Passenger is used. Is it possible to know what WSGI/ASGI server is used without consulting my service provider, possibly through terminal or a Python…
Dante
  • 611
  • 1
  • 7
  • 21
0
votes
1 answer

i want to use asgi2 version application in python

Most applications in Python are using ASGI version 3. For example, in django, asgi supports asgi version 3. How can I use asgi2 version? Even if it's not django Are there any applications that use asgi2, and if so, which ones?
김재영
  • 47
  • 5
0
votes
0 answers

Socket IO + gevent: production ready ASGI server?

I see that Socket.io's python library has a ServerClass that can be used with gevent. It also has an ASGIApp class, and seems to be able to serve that from its server. My question is: if I use that ServerClass and ASGIApp along with gevent, is it…
augray
  • 3,043
  • 1
  • 17
  • 30
0
votes
0 answers

How do I start/stop Hypercorn/Uvicorn server as a background task for an async application (like a discord bot) Python

I am currently creating a django application w/ asgi and I am currently having problems of setting up hypercorn and uvicorn to run in background with graceful shutdown. When I set up my application from asgi to run on hypercorn only using…
Paul Li
  • 1
  • 1
0
votes
0 answers

Django Channels - Websocket connection failed (production)

I decided to add websockets to my project in order to communicate with the database instantly. But at first I decided to just check if websockets will work on production. I made a test version with chat from Django documentation. To my deep regret…
Aleksey
  • 1
  • 1
0
votes
0 answers

I can´t publish MQTT messages after a few days

I'm using "mqttasgi" as library with Django justo to listen and posting many messages. However, for some reason after a few days it is no longer possible to continue posting messages. It should be noted that I am using the amazon login with…
0
votes
2 answers

Django with mqttasgi, how to update the db with contents of received messages

I have a Django project that reads messages from mqtt using mqttasgi I can see the messages in the mqttasgi output mqttasgi --host localhost --port 1883 myapp.asgi:application 2023-01-10 18:08:55.380206 -- Received a message at topic:…
0
votes
0 answers

What is the correct way to configure ASGI application for channels in Django?

I've just started to learn about channels and asgi in django in few tutorials that i've seen they do this to configure the asgi apllication asgi.py import os from django.core.asgi import get_asgi_application from channels.routing import…
0
votes
0 answers

django.urls.base.get_script_prefix returns incorrect prefix when executed by apache

Python-3.8/Django-3.2/Mezzanine-6.0 application tries to access incorrect pages when executed by apache. In standalone mode (python manage.py runserver) it creates correct address /admin/page_types/basicpage/2677/change/ whereas in apache mode it…
Jaana
  • 266
  • 1
  • 3
  • 14
0
votes
0 answers

Channels development server does not taking over my Django development server

I'm learning django(4.1) channels(4.0.0) from a YouTube video and now trying to configure ASGi. Using windows and gitbash. After configuration when I run server, instead of showing: Starting ASGI/Channels version 4.0.0 development server at…
Help
  • 1
  • 5
0
votes
1 answer

Is there a way to enable secure websockets on Django?

I can't use secure websockets on Django with the sll enabled. I use the sslserver package for Django to allow HTTPS on the development server. My goal is to make a secure chat. Here is the configuration : INSTALLED_APPS = [ 'channels', …
MalloryLP
  • 5
  • 5
0
votes
1 answer

Hypercorn server hooks

I have seen that gunicorn provide server hooks that we can use to hook on the various server event , I am looking for the same in hypercorn as it is inspired on gunicorn , but the hypercorn documentation is not of any help in this matter and i…
abhay katiyar
  • 115
  • 1
  • 5