Skip to content

Commit 404373f

Browse files
committed
Lazy construction of data converter with context on WorkflowHandle
1 parent bb58344 commit 404373f

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

temporalio/client.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import asyncio
77
import copy
88
import dataclasses
9+
import functools
910
import inspect
1011
import json
1112
import re
@@ -1598,11 +1599,6 @@ def __init__(
15981599
) -> None:
15991600
"""Create workflow handle."""
16001601
self._client = client
1601-
self._data_converter = client.data_converter._with_context(
1602-
temporalio.converter.WorkflowSerializationContext(
1603-
namespace=client.namespace, workflow_id=id
1604-
)
1605-
)
16061602
self._id = id
16071603
self._run_id = run_id
16081604
self._result_run_id = result_run_id
@@ -1611,6 +1607,14 @@ def __init__(
16111607
self._start_workflow_response = start_workflow_response
16121608
self.__temporal_eagerly_started = False
16131609

1610+
@functools.cached_property
1611+
def _data_converter(self) -> temporalio.converter.DataConverter:
1612+
return self._client.data_converter._with_context(
1613+
temporalio.converter.WorkflowSerializationContext(
1614+
namespace=self._client.namespace, workflow_id=self._id
1615+
)
1616+
)
1617+
16141618
@property
16151619
def id(self) -> str:
16161620
"""ID for the workflow."""

0 commit comments

Comments
 (0)