I also confirm that this bug renders the current installation of fastapi in Ubuntu 22.04 unusable. I have used a virtual environment to install a new version of fastapi while using the rest of the packages from the system as follows:
As previous comment said, version 0.76 of fastapi would be compatible with the installed versions of both starlette and uvicorn and will solve the issue.
I also confirm that this bug renders the current installation of fastapi in Ubuntu 22.04 unusable. I have used a virtual environment to install a new version of fastapi while using the rest of the packages from the system as follows:
# python3 -m venv --system- site-packages
# pip install fastapi==0.76
I then have tested that with the following self-contained test works fine:
import requests
import threading
import unittest
from time import sleep
import uvicorn.server
from fastapi import FastAPI
app = FastAPI()
@app.get("/ping")
def get_object() :
return {"ping": "OK"}
class FastAPITest( unittest. TestCase) : server. Server = None
server: uvicorn.
def __init__(self, args):
super( ).__init_ _(args)
@classmethod
uvicorn_ config = Config(app, port=8888, host="localhost")
FastAPITest. server = Server( config= uvicorn_ config)
threading. Thread( target= FastAPITest. server. run).start( )
def setUpClass(cls):
from uvicorn.config import Config
from uvicorn import Server
sleep(1)
@classmethod
FastAPITest. server. should_ exit = True
def tearDownClass(cls):
sleep(1)
def test_ping(self):
requests. get("http:// localhost: 8888/ping")
As previous comment said, version 0.76 of fastapi would be compatible with the installed versions of both starlette and uvicorn and will solve the issue.