Skip to content

Commit 567d5c4

Browse files
committed
memoize data converter construction in paging iterator
1 parent 404373f commit 567d5c4

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

temporalio/client.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3226,15 +3226,24 @@ async def fetch_next_page(self, *, page_size: Optional[int] = None) -> None:
32263226
metadata=self._input.rpc_metadata,
32273227
timeout=self._input.rpc_timeout,
32283228
)
3229+
3230+
data_converter_cache = {}
3231+
3232+
def get_data_converter(workflow_id: str) -> temporalio.converter.DataConverter:
3233+
if workflow_id not in data_converter_cache:
3234+
data_converter_cache[workflow_id] = (
3235+
self._client.data_converter._with_context(
3236+
WorkflowSerializationContext(
3237+
namespace=self._client.namespace,
3238+
workflow_id=workflow_id,
3239+
)
3240+
)
3241+
)
3242+
return data_converter_cache[workflow_id]
3243+
32293244
self._current_page = [
32303245
WorkflowExecution._from_raw_info(
3231-
v,
3232-
self._client.data_converter._with_context(
3233-
WorkflowSerializationContext(
3234-
namespace=self._client.namespace,
3235-
workflow_id=v.execution.workflow_id,
3236-
)
3237-
),
3246+
v, get_data_converter(v.execution.workflow_id)
32383247
)
32393248
for v in resp.executions
32403249
]

0 commit comments

Comments
 (0)