Closed FingerLiu closed 7 years ago
Flask itself does not support asyncio, you have a bigger problem than this extension.
If you want to use Socket.IO with asyncio, then you have to drop Flask. See python-socketio, which is a dependency of this extension that does support asyncio.
Thank you for your great excellent work on python and socketio
Now that Flask supports asyncio, is there a workaround?
No. Flask does not have good support for asyncio, it just allows you to define async handlers. I'm not planning to implement something like Flask's support for asyncio because it isn't very useful, in my opinion. The python-socketio package has real support for asyncio. If you want to write an async application then I suggest you drop Flask and use python-socketio directly, or along an async web framework such as FastAPI, Sanic or Quart.
Thanks for your quick response. The problem I'm having is that flask-socketio is blocking, which is inherent as you pointed out
The only problem I have with that idea is that I want to forward one port for both HTTP and socket.io
, rather then have separate ports for the websocket and the web server, which this package can somehow do. Are there any other packages like this one that are non-blocking? I've searched but there doesn't seem to be packages similar to this one for other frameworks
@Anonymous941 Flask-SocketIO is not blocking, I'm not sure from where you obtained this incorrect detail.
If your server is blocking, then I suggest you review what your application does. If you are using eventlet or gevent for asynchronous operation, then it is common for applications to inadvertently introduce blocking functions. You may also consider using the threading
async mode and drop eventlet/gevent. The threading mode uses regular threads for concurrency and in general does not have a problem with CPU intensive work, which would block under eventlet or gevent.
Flask-SocketIO is not blocking, I'm not sure from where you obtained this incorrect detail.
Okay, never mind, it turns out to be a bug in my code that happened to look exactly like something was blocking, and got triggered (coincidentally) only once I started using Flask-SocketIO. Sorry to waste your time
Did not find any info about asyncio, will asyncio be supported or not?