asgi

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

Is having a concurrent.futures.ThreadPoolExecutor call dangerous in a FastAPI endpoint? Question: 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/’, ‘http://some-made-up-domain.com/’] # Retrieve a single page and report the URL and contents def load_url(url, timeout): with urllib.request.urlopen(url, timeout=timeout) as conn: return conn.read() # We can use a with …

Total answers: 1

How do I write an ASGI compliant middleware (while staying framework-agnostic)?

How do I write an ASGI compliant middleware (while staying framework-agnostic)? Question: We’re currently maintaining code written in several HTTP frameworks (Flask, aiohttp and FastAPI). Rewriting them so they all use the same framework is currently not feasible. There’s some code that I’d like to share across those applications and that would be very well …

Total answers: 2

Architecture Flask vs FastAPI

Architecture Flask vs FastAPI Question: I have been tinkering around Flask and FastAPI to see how it acts as a server. One of the main things that I would like to know is how Flask and FastAPI deal with multiple requests from multiple clients. Especially when the code has efficiency issues (long database query time). …

Total answers: 5

Gunicorn gevent workers vs Uvicorn ASGI

Gunicorn gevent workers vs Uvicorn ASGI Question: I’m currently developing a service in Django which makes use of a slow external API (takes about 10s to get a response), which means the connections to my server are kept open waiting for the external API to respond, and occupying worker time/resources. I know I can use …

Total answers: 1

uvicorn is not working when called from the terminal

uvicorn is not working when called from the terminal Question: I tried installing uvicorn on the system via pip3 which worked, however i am unable to run the same from the command line. Any pointers as to how to resolve this? Requirement already satisfied: uvicorn in /home/vhawk19/.local/lib/python3.7/site-packages (0.10.8) Requirement already satisfied: uvloop>=0.14.0; sys_platform != “win32” …

Total answers: 10

Graceful shutdown of uvicorn starlette app with websockets

Graceful shutdown of uvicorn starlette app with websockets Question: Given this sample Starlette app with an open websocket connection, how do you shut down the Starlette app? I am running on uvicorn. Whenever I press Ctrl+C the output is Waiting for background tasks to complete. which hangs forever. from starlette.applications import Starlette app = Starlette() …

Total answers: 2

django.core.exceptions.ImproperlyConfigured: Cannot import ASGI_APPLICATION module 'routing'

django.core.exceptions.ImproperlyConfigured: Cannot import ASGI_APPLICATION module 'routing' Question: I am trying to build a multiplayer game in Django, for which I needed to work on Django channels. but here’s the issue while running it. Performing system checks… System check identified no issues (0 silenced). September 27, 2019 – 05:38:35 Django version 2.2.5, using settings ‘multiproject.settings’ Starting …

Total answers: 2