648 questions
1
vote
1
answer
118
views
Uvicorn /FastAPI strange behavior
I create simple app using (python 3.11, uvicorn 0.38.0, fastapi 0.120.2):
import os
import time
import asyncio
import uvicorn
from fastapi import FastAPI
from fastapi import BackgroundTasks
app = ...
0
votes
0
answers
34
views
“Operation not permitted” when creating directories and saving files in Azure App Service (FastAPI on Linux)
I’m hosting a FastAPI application on Azure App Service (Linux, Python 3.12).
The deployment works, but the logs repeatedly show the following errors:
chown: changing ownership of '/temp': Operation ...
2
votes
1
answer
59
views
How to ensure webhook requests are routed to the same FastAPI worker that initiated the request
I’m working on a FastAPI service deployed with Uvicorn using multiple workers to handle voice communication with Twilio, and I’m running into a routing problem.
Current architecture:
A client sends a ...
0
votes
0
answers
132
views
Uvicorn not getting trace id from otel in error logs (trace_id=0)
I have a test FastAPI application:
from fastapi import FastAPI, Request
from opentelemetry.exporter.otlp.proto.grpc import trace_exporter
from opentelemetry.instrumentation.asgi import ...
0
votes
0
answers
54
views
How to set cookie for data block in config.yaml of continue?
I'm trying to capture chatInteraction and chatFeedback from continue with below config details in config.yaml of continue plugin.
But I see no response and no logs being printed during debug in ...
0
votes
2
answers
95
views
FastAPI and uvicorn not updating
I've got 2 separate issues with FastAPI. I'm going through a course and on the tagging part, my tags aren't showing in the docs. Additionally, for 1 endpoint that I provided status codes (default to ...
2
votes
0
answers
291
views
Uvicorn workers greater than one apparently reduce performance by half
Update 2: The following results do not hold when installing Uvicorn using pip install uvicorn[standard] which installs Uvicorn with Cython-based dependencies (where possible) and other optional extras....
2
votes
0
answers
83
views
Python uvicorn app opens a cmd - how to stop it?
I've been building a WebSocket application and I opted for Python FastAPI + Uvicorn for server side. Having pretty much finished the app, I decided to pack the server into an .exe file. Even though I ...
0
votes
1
answer
534
views
FastAPI WebSocket returns 403 Forbidden when trying to access via Postman
I am trying to run a websocket from a server where it watches a file and broadcasts any changes to the file over the websocket. This is my code:
import os
import json
import uvicorn
import asyncio
...
0
votes
0
answers
131
views
FastAPI Dev taking very long to start the server whereas uvicorn main:app --reload --port 8000 works
I have a very simple FastAPI server.
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
def read_root():
return {"message": "Hello, World!"}
@app.get("/...
1
vote
1
answer
473
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 ...
4
votes
0
answers
482
views
Gunicorn / Uvicorn extremely rare 502 Errors
We observed an issue with our containerized Python FastAPI application, which we deploy using Gunicorn and Uvicorn on Kubernetes. In extremely rare cases (~1 in 100.000) a single request seem to be ...
3
votes
0
answers
156
views
Limit FastAPI/gunicorn/... worker to certain endpoints to save memory
I have a FastAPI application with multiple endpoints, and each endpoint uses certain memory intensive objects (ML models). This works fine when I only have one worker, but I am worried about memory ...
0
votes
1
answer
991
views
My FastAPI service is giving CORS errors from my website running on localhost when I run the API in VSCode, but not if I run it on the command line
I have an API built in FastAPI hosted with uvicorn. I also have a website build in next.js. My typical workflow is to run the API locally on the command line and it will be hosted on localhost:8000, ...
1
vote
1
answer
884
views
Port in code not being included when starting my Python Uvicorn app?
I have my code starting as such:
if __name__ == "__main__":
uvicorn.run(
app,
host="0.0.0.0",
port=3001, # Desired port.
)
I'm starting my ...
2
votes
0
answers
191
views
How can I run Uvicorn in ECS?
I have a FastAPI/Uvicorn/SQLAlchemy app that I'm trying to run in ECS. I have successfully run the app via docker compose, but when I try to deploy the container in ecs I get the following error:
...
1
vote
0
answers
181
views
Twilio POST request showing GET error: 405 Method Not Allowed
The issue is when Twilio sends a POST request to the /incoming-call endpoint, my server is returning a 405 Method Not Allowed error. The error log also shows that the server is attempting to handle ...
1
vote
0
answers
170
views
Python: FastAPI not accepting SQLModel as a return type on routes
I'm making an API based on the FastAPI docs (https://fastapi.tiangolo.com/tutorial/sql-databases/#install-sqlmodel). I have noticed this docs are kind of deprecated due to @app.on_event("startup&...
0
votes
1
answer
324
views
invalid command name 'main:app' when I execute "uvicorn main:app --reload" [duplicate]
When I try to execute the command uvicorn main:app --reloadfor start my local server, the VSCode terminal throws the error invalid command name 'main:app'. The code below imports a variable from the ...
1
vote
1
answer
89
views
GCP Cloud Run Container Behavior - ModuleNotFoundError
When Cloud Run runs a container image, the container fails differently than when I run it locally.
I added this try/except in app/main.py to debug the divergent behaviors:
print(f'cwd is {os.getcwd()}'...
0
votes
0
answers
486
views
WebSocket Disconnects After 60-70 Seconds in FastAPI (Uvicorn) – Works in Postman, Fails in Browser and Mobile Clients
I’m implementing a WebSocket connection using FastAPI with Uvicorn as the server. The WebSocket works fine when tested through Postman, but disconnects after 60-70 seconds when accessed through web ...
0
votes
0
answers
154
views
How do I connect uvicorn/fastapi through docker container?
I'm currently building an app that connects to an API server through a script. Here’s how I create posts by connecting to the API server:
api_url = "http://localhost:8013/posts/"
...
0
votes
1
answer
267
views
Python FastAPI no console mode with Uvicorn
I am building an app. While deploying in Windows server I don't want the console opening. But when I try to do so in .pyw form it does noting
run.pyw 1>stdout.txt 2>stderr.txt calls the ...
0
votes
1
answer
604
views
Unable to run Uvicorn server/FastAPI app through Docker [duplicate]
I am new to computer networks and Docker, and I'm trying to deploy and run a small FastAPI app using Docker. The app works successfully when I run it locally with Uvicorn, but it fails to run when I ...
0
votes
0
answers
65
views
Update deep learning models to memory every day with Uvicorn FastAPI without reloading
I have a FastAPI backend that needs to load new deep learning models everyday to memory. Models loads for the first time when FastAPI starts or force reload.
I have a class Predict and an endpoint to ...