Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 4 additions & 1 deletion temporalio/worker/_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,10 @@ def client(self, value: temporalio.client.Client) -> None:
must be using the same runtime as the current client.
"""
bridge_client = _extract_bridge_client_for_worker(value)
if self._runtime is not bridge_client.config.runtime:
new_runtime = (
bridge_client.config.runtime or temporalio.runtime.Runtime.default()
Comment thread
Sakshamm-Goyal marked this conversation as resolved.
Outdated
)
if self._runtime is not new_runtime:
raise ValueError(
"New client is not on the same runtime as the existing client"
)
Expand Down
11 changes: 11 additions & 0 deletions tests/worker/test_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -6279,6 +6279,17 @@ async def test_workflow_replace_worker_client_diff_runtimes_fail(
worker.client = other_client


async def test_workflow_replace_worker_client_default_runtime(client: Client):
# Do not pass a runtime here: this client should lazily use the same
# default runtime as the worker.
default_runtime_client = await Client.connect(
client.service_client.config.target_host,
namespace=client.namespace,
)
async with new_worker(client, HelloWorkflow) as worker:
worker.client = default_runtime_client


@activity.defn(dynamic=True)
async def return_name_activity(_args: Sequence[RawValue]) -> str:
return activity.info().activity_type
Expand Down