Skip to content

Commit c78016e

Browse files
committed
Ensure _any_converter_takes_context is set and not stale
1 parent a8e3c67 commit c78016e

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

temporalio/converter.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import collections
66
import collections.abc
77
import dataclasses
8+
import functools
89
import inspect
910
import json
1011
import sys
@@ -352,9 +353,6 @@ def __init__(self, *converters: EncodingPayloadConverter) -> None:
352353
converters: Payload converters to delegate to, in order.
353354
"""
354355
self._set_converters(*converters)
355-
self._any_converter_takes_context = any(
356-
isinstance(c, WithSerializationContext) for c in converters
357-
)
358356

359357
def _set_converters(self, *converters: EncodingPayloadConverter) -> None:
360358
self.converters = {c.encoding.encode(): c for c in converters}
@@ -453,6 +451,12 @@ def get_converters_with_context(
453451

454452
return converters if any_with_context else None
455453

454+
@functools.cached_property
455+
def _any_converter_takes_context(self) -> bool:
456+
return any(
457+
isinstance(c, WithSerializationContext) for c in self.converters.values()
458+
)
459+
456460

457461
class DefaultPayloadConverter(CompositePayloadConverter):
458462
"""Default payload converter compatible with other Temporal SDKs.

0 commit comments

Comments
 (0)