Skip to content

Commit da6b55a

Browse files
committed
Reduce entity context exposure
1 parent eba1e8e commit da6b55a

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

durabletask/worker.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,7 @@ class _RuntimeOrchestrationContext(task.OrchestrationContext):
776776
_generator: Optional[Generator[task.Task, Any, Any]]
777777
_previous_task: Optional[task.Task]
778778

779-
def __init__(self, instance_id: str, registry: _Registry, entity_context: OrchestrationEntityContext):
779+
def __init__(self, instance_id: str, registry: _Registry):
780780
self._generator = None
781781
self._is_replaying = True
782782
self._is_complete = False
@@ -791,7 +791,7 @@ def __init__(self, instance_id: str, registry: _Registry, entity_context: Orches
791791
self._current_utc_datetime = datetime(1000, 1, 1)
792792
self._instance_id = instance_id
793793
self._registry = registry
794-
self._entity_context = entity_context
794+
self._entity_context = OrchestrationEntityContext(instance_id)
795795
self._version: Optional[str] = None
796796
self._completion_status: Optional[pb.OrchestrationStatus] = None
797797
self._received_events: dict[str, list[Any]] = {}
@@ -1225,22 +1225,19 @@ def __init__(self, registry: _Registry, logger: logging.Logger):
12251225
self._logger = logger
12261226
self._is_suspended = False
12271227
self._suspended_events: list[pb.HistoryEvent] = []
1228-
self._entity_state: Optional[OrchestrationEntityContext] = None
12291228

12301229
def execute(
12311230
self,
12321231
instance_id: str,
12331232
old_events: Sequence[pb.HistoryEvent],
12341233
new_events: Sequence[pb.HistoryEvent],
12351234
) -> ExecutionResults:
1236-
self._entity_state = OrchestrationEntityContext(instance_id)
1237-
12381235
if not new_events:
12391236
raise task.OrchestrationStateError(
12401237
"The new history event list must have at least one event in it."
12411238
)
12421239

1243-
ctx = _RuntimeOrchestrationContext(instance_id, self._registry, self._entity_state)
1240+
ctx = _RuntimeOrchestrationContext(instance_id, self._registry)
12441241
try:
12451242
# Rebuild local state by replaying old history into the orchestrator function
12461243
self._logger.debug(

0 commit comments

Comments
 (0)