Skip to content

A feature-rich command-line audio/video downloader

[test:websockets] Update server hang workaround (#17718)

doe10809dd5e68cd7ad
diff --git a/test/test_websockets.py b/test/test_websockets.py
index 2b8488625d..57d5576875 100644
--- a/test/test_websockets.py
+++ b/test/test_websockets.py
@@ -130,7 +130,11 @@ def ws_validate_and_send(rh, req):
try:
return rh.send(req)
except TransportError as e:
- if i < (max_tries - 1) and 'connection closed during handshake' in str(e):
+ if i < (max_tries - 1) and (
+ 'connection closed during handshake' in str(e)
+ or (isinstance(e.cause, websockets.exceptions.InvalidMessage)
+ and isinstance(e.cause.__cause__, EOFError))
+ ):
# websockets server sometimes hangs on new connections
continue
raise