Skip to content Skip to sidebar Skip to footer

How Do You Prevent An Instance Using A Socketio.AsyncClient Code From Blocking?

I am struggling with the following piece of code. Once instantiated, it is intended to be a component of a containing object. In my mind the containing object should be able to ins

Solution 1:

The problem here is not that the wait() call on the Socket.IO client is mandatory, it is that without the wait you are exiting the loop immediately after connecting.

Your startup method calls the connect method and then waits for the connection to end. If you call run_until_complete() on this method everything works great.

But if you remove the wait() call, the asyncio loop will exit immediately after connecting, and not in a graceful way. If you want to remove the wait(), then you need to have something in your main task that keeps the loop going. That is the only requirement for the Socket.IO client to continue working.


Post a Comment for "How Do You Prevent An Instance Using A Socketio.AsyncClient Code From Blocking?"