You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a client program that, when started, receives information from the server, processes it, and then sends the result back to the server. However, I have encountered an issue: after the client processes a batch of data, it enters a frozen state where all coroutines stop running. It remains in this state until I press Ctrl+C to exit. By this time, the server has already disconnected due to not receiving a 'pong' in time. The client then restarts the connection and the cycle repeats.
It seems that when the log mentioned above is being output, only the coroutine for await websocket.recv() is running. It appears that this is causing a blockage in the entire coroutine loop. Even when I replaced it with await asyncio.wait_for(websocket.recv(), 60), it still causes a blockage.
Please help me solve this problem. Thanks
The text was updated successfully, but these errors were encountered:
This doesn't look like a bug in websockets. With the info you provided, I have no hypothesis of what may cause the issue you're seeing.
There's at least two clear problems in the code but I don't have enough information to tell if and how they could lead to blocking:
every time you create a new connection, you run a new coroutine runningself.listen and it isn't guaranteed that self.listen terminates when that connection closes (because the definition of self.websocket can change while self.listen is running)
This problem is not consistently reproducible.
I have a client program that, when started, receives information from the server, processes it, and then sends the result back to the server. However, I have encountered an issue: after the client processes a batch of data, it enters a frozen state where all coroutines stop running. It remains in this state until I press Ctrl+C to exit. By this time, the server has already disconnected due to not receiving a 'pong' in time. The client then restarts the connection and the cycle repeats.
Here is my sample code.
The log is probably something like this.
At this point, it entered a frozen state. When I press Ctrl+C, the following log is output.
It seems that when the log mentioned above is being output, only the coroutine for await websocket.recv() is running. It appears that this is causing a blockage in the entire coroutine loop. Even when I replaced it with await asyncio.wait_for(websocket.recv(), 60), it still causes a blockage.
Please help me solve this problem. Thanks
The text was updated successfully, but these errors were encountered: