-
-
Notifications
You must be signed in to change notification settings - Fork 569
Description
Current implementation of websockets.asyncio.connection.Connection.recv replaces all RuntimeError exceptions removing the relevant stacktrace underneath. Specifically:
try:
...
except EOFError:
...
except RuntimeError:
raise RuntimeError(
"cannot call recv while another coroutine "
"is already running recv or recv_streaming"
) from None # <-- This replaces another valid RuntimeError
Quick link to the code on version 13.0.1: https://github.com/python-websockets/websockets/blob/13.0.1/src/websockets/asyncio/connection.py#L273
This is an issue as Python asyncio throws most other errors also as a RuntimeError. Specifically, the error that was being covered up in my case was an exception regarding a closed Eventloop.
If there is control over the original exception, perhaps a custom exception is more suitable? Or if there is no control, perhaps we should check the msg
in the RuntimeError
if it contains a certain string to ensure this code is replacing the proper RuntimeError? I am unsure which case is being covered here with this error.