Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions gateway/platforms/feishu.py
Original file line number Diff line number Diff line change
Expand Up @@ -1273,7 +1273,14 @@ def _configure_with_overrides(conf: Any) -> Any:
_apply_runtime_ws_overrides()
return result

ws_client_module.websockets.connect = _connect_with_overrides
# Create a local copy of the websockets module to avoid monkey-patching
# the global module (which would break DingTalk and other platforms).
import types
local_websockets = types.ModuleType('websockets')
local_websockets.__dict__.update(ws_client_module.websockets.__dict__)
local_websockets.connect = _connect_with_overrides
ws_client_module.websockets = local_websockets

if original_configure is not None:
setattr(ws_client, "_configure", _configure_with_overrides)
_apply_runtime_ws_overrides()
Expand All @@ -1282,7 +1289,8 @@ def _configure_with_overrides(conf: Any) -> Any:
except Exception:
pass
finally:
ws_client_module.websockets.connect = original_connect
# Restore the original websockets module reference
ws_client_module.websockets = ws_client_module.websockets.__dict__.get('__original_module__', ws_client_module.websockets)
if original_configure is not None:
setattr(ws_client, "_configure", original_configure)
pending = [t for t in asyncio.all_tasks(loop) if not t.done()]
Expand Down