Skip to main content

All Questions

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 ...
Roman Gelembjuk's user avatar
0 votes
1 answer
96 views

Why is await queue.get() Blocking and Causing My Async Consumers to Hang?

I’m having trouble with an asynchronous queue. Specifically, the await queue.get() seems to block the rest of my application, causing it to hang. I came across a similar issue discussed here: Why is ...
jda5's user avatar
  • 1,456
1 vote
1 answer
74 views

Keep a variable between two threads in python [duplicate]

I'm using python Fastapi. I am running an application that at one point launches a job to an external service. The service then sends a webhook with the job's status, a status I receive in an endpoint ...
Ingrid5's user avatar
  • 11
1 vote
1 answer
205 views

AttributeError: 'function' object has no attribute 'submit' [duplicate]

I am using fastapi and uvicorn as my python server and whenever a user visits a route, I want to start a subprocess in the background. I used asyncio.create_task and loop.run_in_excutor in order to ...
Zaid's user avatar
  • 87
2 votes
2 answers
533 views

FastAPI TestClient not starting lifetime in test

Example code: import os import asyncio from contextlib import asynccontextmanager from fastapi import FastAPI, Request @asynccontextmanager async def lifespan(app: FastAPI): print(f'Lifetime ON {...
WebOrCode's user avatar
  • 7,322
0 votes
1 answer
66 views

Python asyncio + multiprocessing [duplicate]

I am trying to create a server with fastapi with multiprocessing, where you can send an image to a given endpoint, and it will be processed concurrently via 3 different ocr models to recognize text. ...
ReYaN WTF's user avatar
-1 votes
1 answer
265 views

Python asyncio.gather not really parallel? [duplicate]

So I am trying to understand the parallelism in asyncio.gather() function. I have a FastAPI app that needs to upload 4 files to s3 at the same time. I am using a local S3 for testing right now, so ...
doglover1337's user avatar
0 votes
0 answers
174 views

FastAPI is not working like expected in Async Mode [duplicate]

I need to build an API using FastAPI with the following requirements: Should be Async Accepts a PDF and input Split the pdf to images call 3 api endpoints for each image synchronously It should be ...
Shreyas M Kaushik's user avatar
1 vote
0 answers
509 views

Validate model with sqlalchemy AsyncSession

I have a FastAPI server and a PostgresSQL database integrated using sqlalchemy. This is the dependency to get the database (I'm following sqlalchemy async best practicies): import os from sqlalchemy ...
Fral's user avatar
  • 31
5 votes
2 answers
4k views

Call async function from sync inside async FastAPI application

Not sure, that this is possible, but still I have default async FastAPI application, where I have sync function @classmethod def make_values( cls, records: list, symbol: str = ...
Headmaster's user avatar
  • 2,342
3 votes
1 answer
1k views

FastAPI async routes deadlock bug when using infinite loop [duplicate]

I am experiencing an issue with FastAPI where the application gets deadlocked when using an infinite loop in an async route. Here is a simplified version of my FastAPI application (fastapi_test.py): ...
tombreplacer's user avatar
1 vote
0 answers
52 views

How to call a route once in Fastapi and block calling it again (display a "process running" message) until execution completes

There is a need to wait for a function to be executed and to protect it from being called again. It is necessary to protect the route call from being called again; if the route is called again while ...
MadInc's user avatar
  • 11
0 votes
1 answer
175 views

how fastapi async works? [duplicate]

I have this small fastapi application # run_sync_8001.py import time import uvicorn from fastapi import FastAPI, Query app = FastAPI() @app.get("/") def sleep(n: int = Query()): time....
Amin Ba's user avatar
  • 2,465
12 votes
2 answers
19k views

What does async actually do in FastAPI? [duplicate]

I have two scripts: from fastapi import FastAPI import asyncio app = FastAPI() @app.get("/") async def root(): a = await asyncio.sleep(10) return {'Hello': 'World',} And second ...
filtertips's user avatar
1 vote
1 answer
940 views

Convert Blocking python function to async function [duplicate]

So currently I have 4 api requests which are called in synchronous method using a third_party lib which is synchronous. What i want is to run them in parallel. So that my total time to call all 4 apis ...
Abhishek Sachan's user avatar

15 30 50 per page