[rh:websockets] Add legacy connect workaround for >=17.1 (#17747)

Authored by: bashonly
This commit is contained in:
bashonly
2026-09-27 20:17:39 +00:00
committed by GitHub
parent caf63903a1
commit a29f2a2b92
+5
View File
@@ -164,6 +164,11 @@ class WebsocketsRH(WebSocketRequestHandler):
user_agent_header=None,
ssl=ssl_ctx if wsuri.secure else None,
close_timeout=0, # not ideal, but prevents yt-dlp hanging
# Workaround for websockets>=17.1 support:
# connect() is intended to be used as a context manager and other usage has been deprecated.
# The `legacy` flag was added in 17.1 for backwards compat and has not yet been deprecated.
# Ref: https://github.com/python-websockets/websockets/commit/1f7f0e537233ac82e4ca51921678963c696c8c08
**({'legacy': True} if websockets_version >= (17, 1) else {}),
)
return WebsocketsResponseAdapter(conn, url=request.url)