[Python] Error at every reload of Uvicorn + FastAPI

Discussão em 'Python' iniciado por Stack, Abril 8, 2025.

  1. Stack

    Stack Membro Participativo

    I get this error every time I save. Besides, it takes a while to recharge.

    I have tried several versions of Python with the same result. I try to execute the example code.

    Can somebody help me?

    INFO: Application startup complete.
    WARNING: WatchFiles detected changes in 'main.py'. Reloading...
    INFO: Shutting down
    INFO: Waiting for application shutdown.
    INFO: Application shutdown complete.
    INFO: Finished server process [5164]
    Process SpawnProcess-1:
    Traceback (most recent call last):
    File "C:\Users\x\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 118, in run
    return self._loop.run_until_complete(task)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\x\AppData\Local\Programs\Python\Python312\Lib\asyncio\base_events.py", line 685, in run_until_complete
    return future.result()
    ^^^^^^^^^^^^^^^
    asyncio.exceptions.CancelledError

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
    File "C:\Users\x\AppData\Local\Programs\Python\Python312\Lib\multiprocessing\process.py", line 314, in _bootstrap
    self.run()
    File "C:\Users\x\AppData\Local\Programs\Python\Python312\Lib\multiprocessing\process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
    File "C:\Users\x\Documents\GitHub\bravissimo\.env\Lib\site-packages\uvicorn\_subprocess.py", line 78, in subprocess_started
    target(sockets=sockets)
    File "C:\Users\x\Documents\GitHub\bravissimo\.env\Lib\site-packages\uvicorn\server.py", line 65, in run
    return asyncio.run(self.serve(sockets=sockets))
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\x\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 194, in run
    return runner.run(main)
    ^^^^^^^^^^^^^^^^
    File "C:\Users\x\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 123, in run
    raise KeyboardInterrupt()
    KeyboardInterrupt
    INFO: Started server process [14264]
    INFO: Waiting for application startup.
    INFO: Application startup complete.


    Package Version


    annotated-types 0.6.0 anyio 4.3.0 click 8.1.7 colorama 0.4.6 fastapi 0.110.0 h11 0.14.0 httptools 0.6.1 idna 3.6 pip 24.0 pydantic 2.6.4 pydantic_core 2.16.3 python-dotenv 1.0.1 PyYAML 6.0.1 sniffio 1.3.1 starlette 0.36.3 typing_extensions 4.10.0 uvicorn 0.29.0 watchfiles 0.21.0 websockets 12.0 Python 3.12.2

    Continue reading...

Compartilhe esta Página