All Questions
199 questions
1
vote
0
answers
44
views
FastAPI Async Setup [duplicate]
I'm working on a FastAPI application where I need to initialize an async service by loading some large backing data files asynchronously. However, I'm running into issues when using fastapi dev (...
2
votes
1
answer
60
views
TypeError in FastAPI when using APIRoute with a Router
I have a FastAPI backend and i'm trying to implement an APIRoute class to handle logic before and after the request (logging).
# app.py
from fastapi import FastAPI, APIRouter
from backend.app.routers ...
1
vote
1
answer
146
views
FastAPI Global Timeout Middleware Not Working for Sync Routes [duplicate]
I am trying to enforce a global request timeout in my FastAPI application using a custom TimeoutMiddleware. The middleware is supposed to cancel any request that takes longer than the specified ...
0
votes
0
answers
23
views
Playwright exception: no description
I have a strange error with no description when I try to use async playwright
This is a FastApi app and I am on Windows
In the docs there is a mention that incompatible with SelectorEventLoop of ...
1
vote
1
answer
104
views
How to make a non-blocking Websocket endpoint in FastAPI? [duplicate]
I'm fairly new to async in Python. Currently I'm trying to implement a Websocket endpoint with FastAPI that performs a long-running task. The following code is used:
@router.websocket("/ws/...
0
votes
0
answers
63
views
Executing command on a pod using asyncio causes exception
I want to execute a long running task on one pod from another. For this I started using subprocess.Popen to accomplish this task which does what I need. However, subprocess.Popen is not asynchronous ...
1
vote
1
answer
381
views
How to upload file in chunks to Google Cloud Storage using FastAPI's request.stream()?
I have a data flow in a FastAPI application where a potentially very large HTTP PUT body is being uploaded, and I need to stream this to Google Cloud Storage. I'm using the gcloud.aio.storage library ...
1
vote
0
answers
45
views
Do APschedular hold CPU resouces while waiting? [duplicate]
I am working on a webhook handler where I process incoming data and update records in my database. Here's the relevant portion of my code:
def handle_rocket_reach_webhook(self, profile_data: any):
...
0
votes
2
answers
124
views
Ensure a singleton variable across entire web app
Background Info
My web app is built on top of async FastAPI. The server deploying this app will start 4 workers and each worker will start 2 threads for handling concurrent requests.
Description
Most ...
0
votes
1
answer
49
views
Async requests with APIRouter or httpx.AsyncClient [closed]
I'm working on a partially developed FastAPI project. Most client requests in this project use FastAPI's built-in APIRouter with asynchronous functions for client requests, they look like this:
from ...
1
vote
1
answer
759
views
How to stop background tasks in a graceful shutdown of FastAPI
Whenever I gracefully shut down my FastAPI app by saving a file (with the --reload option), it waits for all background tasks to be complete before initiating shutdown.
uvicorn INFO: Shutting down
...
0
votes
1
answer
67
views
Stop and resume process by semaphore
I wish to implement an API that utilize asyncio events in order to stop/resume a asyncio task. The API will support the following methods:
/import (start)
/stop
/resume
Main problem is happening ...
1
vote
1
answer
411
views
Custom handler for FastAPI to handle to closure of connections
I have a weird issue with FastAPI. The background story is that I have a queue that consist of jobs that get added when I do a request to a FastAPI endpoint. I am using this to test stuff, so I am ...
0
votes
1
answer
521
views
FastAPI with asyncio | Running long running background tasks
I'm running a heavy async task in FastAPI and need to return a response to the user while continuing the task in the background with asyncio. When I await the task, it works perfectly, but when I add ...
0
votes
1
answer
110
views
How to read async stream from non-async method? [duplicate]
I use FastAPI to create the app. One of features is upload of files with PUT request.
Fast API supports uploading files with POST requests (multipart form).
But I need the PUT request where a file is ...