pyropy / fastapi-socketio

Easily integrate socket.io with your FastAPI app 🚀
Apache License 2.0
328 stars 31 forks source link

How it works with real example (with bigger project structure)? #37

Open michaldev opened 1 year ago

michaldev commented 1 year ago

In my case, I have problem with import everything from main file (with fastapi app object). https://github.com/michaldev/problem-with-fastapi-import

Access to the app object is not required for other libraries.

michaldev commented 1 year ago

I try like this: main.py: socket_manager.attach(app=app) sockets.py: socket_manager = SocketManager(app=None)

by returns AttributeError: 'NoneType' object has no attribute 'mount'

michaldev commented 1 year ago

Solved. I used python-socketio instead of fastapi-socketio and I was able to connect a manager from main that is in a different file. This prevents circular imports.