Does ClientWebSocketResponse.receive()
and ClientWebSocketResponse.close()
ever raise an exception?
#7337
-
^^^^^^^^^^^^ |
Beta Was this translation helpful? Give feedback.
Answered by
Dreamsorcerer
Jul 2, 2023
Replies: 2 comments
-
Well, yes, there's a RuntimeError if you misuse it: A TimeoutError if you use the timeout: Looks like other exceptions are caught and turned into WSMessages though.
|
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
RainerZufall187
-
ok so there is no need for try and except |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Well, yes, there's a RuntimeError if you misuse it:
https://github.com/aio-libs/aiohttp/blob/master/aiohttp/client_ws.py#L238
A TimeoutError if you use the timeout:
https://github.com/aio-libs/aiohttp/blob/master/aiohttp/client_ws.py#L260
Looks like other exceptions are caught and turned into WSMessages though.
close()
looks pretty safe, I wouldn't expect an exception to occur there.