Skip to content

Commit 9dd2654

Browse files
authored
Fix task_any bug (#538)
* Fix long timer bug * Also fix task_any scheduling issue
1 parent ee347c7 commit 9dd2654

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

azure/durable_functions/models/DurableOrchestrationContext.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,8 @@ def _add_to_open_tasks(self, task: TaskBase):
722722
task.id = self._sequence_number
723723
self._sequence_number += 1
724724
self.open_tasks[task.id] = task
725-
elif task.id != -1:
725+
elif task.id != -1 and self.open_tasks[task.id] != task:
726+
# Case when returning task_any with multiple external events having the same ID
726727
self.open_tasks[task.id].append(task)
727728

728729
if task.id in self.deferred_tasks:

azure/durable_functions/models/TaskOrchestrationExecutor.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,14 +245,14 @@ def resume_user_code(self):
245245

246246
self.current_task = new_task
247247
if not (new_task is None):
248+
if not (self.current_task._is_scheduled):
249+
# new task is received. it needs to be resolved to a value
250+
self.context._add_to_actions(self.current_task.action_repr)
251+
self._mark_as_scheduled(self.current_task)
248252
if not (new_task.state is TaskState.RUNNING):
249253
# user yielded the same task multiple times, continue executing code
250254
# until a new/not-previously-yielded task is encountered
251255
self.resume_user_code()
252-
elif not (self.current_task._is_scheduled):
253-
# new task is received. it needs to be resolved to a value
254-
self.context._add_to_actions(self.current_task.action_repr)
255-
self._mark_as_scheduled(self.current_task)
256256

257257
def _mark_as_scheduled(self, task: TaskBase):
258258
if isinstance(task, CompoundTask):

0 commit comments

Comments
 (0)