Skip to content

Commit 77f1542

Browse files
committed
add recursive reentrancy checks for BasicTask run_action run_subtask
1 parent 948fe5e commit 77f1542

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

prime_backup/mcdr/task/basic_task.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,19 @@ def wait_confirm(self, confirm_target_text: Optional[RTextBase] = None, time_wai
8787
self.is_waiting_confirm = False
8888

8989
def run_action(self, action: Action[_S], auto_interrupt: bool = True) -> _S:
90+
if self.__running_action is not None:
91+
raise RuntimeError('Cannot run action twice at the same time, current: {}, new: {}'.format(self.__running_action, action))
9092
self.__running_action = action
91-
if auto_interrupt and self.aborted_event.is_set():
92-
action.interrupt()
9393
try:
94+
if auto_interrupt and self.aborted_event.is_set():
95+
action.interrupt()
9496
return action.run()
9597
finally:
9698
self.__running_action = None
9799

98100
def run_subtask(self, task: Task[_S]) -> _S:
101+
if self.__running_subtask is not None:
102+
raise RuntimeError('Cannot run task twice at the same time, current: {}, new: {}'.format(self.__running_subtask, task))
99103
self.__running_subtask = task
100104
try:
101105
return task.run()

0 commit comments

Comments
 (0)