Default WebSocketProxyClientTask to active=False
``on_activated`` on this task opens the upstream WebSocket connection,
which is almost always something the caller wants to trigger
explicitly (e.g. on local-client-connected). With the BaseTask default
of ``active=True`` the connection was opened twice: once when the task
auto-activated at start, and once again when the caller's
``activate_task("proxy")`` re-fired ``on_activated``. The result on
the remote side was two ``PipelineRunner`` instances per session
instead of one.
Default to ``active=False`` so the activation is a deliberate signal;
pass ``active=True`` explicitly to restore the eager-connect behavior.
This commit is contained in:
@@ -69,6 +69,7 @@ class WebSocketProxyClientTask(BaseTask):
|
||||
forward_messages: tuple[type[BusMessage], ...] = (),
|
||||
headers: dict[str, str] | None = None,
|
||||
serializer: MessageSerializer | None = None,
|
||||
active: bool = False,
|
||||
):
|
||||
"""Initialize the WebSocketProxyClientTask.
|
||||
|
||||
@@ -88,8 +89,13 @@ class WebSocketProxyClientTask(BaseTask):
|
||||
handshake (e.g. for authentication).
|
||||
serializer: Serializer for bus messages. Defaults to
|
||||
`JSONMessageSerializer`.
|
||||
active: Whether the task starts active. Defaults to ``False``
|
||||
because ``on_activated`` opens the WebSocket connection,
|
||||
which is almost always a deliberate action triggered by an
|
||||
upstream event (e.g. the local client connecting). Pass
|
||||
``True`` to connect as soon as the task starts.
|
||||
"""
|
||||
super().__init__(name)
|
||||
super().__init__(name, active=active)
|
||||
self._url = url
|
||||
self._remote_task_name = remote_task_name
|
||||
self._local_task_name = local_task_name
|
||||
|
||||
Reference in New Issue
Block a user