I recently added sockets
to my application, and since then the reload
no longer works but gets stuck in the ‘Shutting down’ status
Here is a screenshot of the logs in the application.
Capture logs when saving changes:
Here is the content of my socket.py
file
from api.configs.logging import logDebug
import socketio
server = socketio.AsyncServer(
cors_allowed_origins="*",
async_mode="asgi",
logger=True,
engineio_logger=True,
ping_interval=30,
ping_timeout=60,
)
@server.event
async def connect(sid, x, y):
logDebug(f"client {sid} connected")
print(f"client {sid} connected")
await server.emit("hello", f"you are connected with sid {sid}", to=sid)
Here is part of my __init__.py
file the contents of my socket.py file
app = FastAPI(
title="TRANSIT MASTER API",
lifespan=LifeSpan,
)
# ----mount socket------
sm = socket.socketio.ASGIApp(socket.server, socketio_path="socket.io")
app.mount("/ws", sm)
app.sio = socket.server
Here is the content of my run.py
file
from api import createApp, SETTINGS
app = createApp(SETTINGS())
if __name__ == "__main__":
import uvicorn
uvicorn.run("run:app", port=80, host="0.0.0.0", reload=True)
Please help me resolve the problem.
3