Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

216
Views
Las solicitudes paralelas de FastAPI no funcionan en Python
from fastapi import FastAPI import uvicorn app = FastAPI() #Some long processing code, with async declaration async def doBTask(): print ("Request started") #asyncio.sleep(20) sum = 0 for n in range (1, 10000): for m in range(1,10000): if m%n ==0: pass else: sum = sum + n print ("Completed") return sum @app.get("/") async def read_root(): result = await doBTask() return {"Result": result} uvicorn.run(app, host="0.0.0.0", port=7000)

Cuando llamamos a esa URL en diferentes pestañas, la salida viene una tras otra (incluso se imprime también). Es claramente un procesamiento único pero no un procesamiento de solicitudes en paralelo. ¿Alguien puede indicar dónde está el error y por qué FastAPI con async y await no funcionan?

Editar Aquí está la respuesta que obtengo si lo pruebo en diferentes navegadores y parámetros ficticios (puede ver, se está procesando uno tras otro, aunque envié todo a la vez)

 Request started Completed INFO: 127.0.0.1:58998 - "GET /?n=10 HTTP/1.1" 200 OK Request started Completed INFO: 127.0.0.1:59012 - "GET /?m=30 HTTP/1.1" 200 OK Request started Completed INFO: 127.0.0.1:59288 - "GET / HTTP/1.1" 200 OK
over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!