@@ -217,29 +217,28 @@ def get_task_from_id(self, task_id):
217
217
def reset_from_task_id (self , task_id , data = None , remove_subprocess = True ):
218
218
219
219
task = self .get_task_from_id (task_id )
220
- run_task_at_end = False
221
- if isinstance (task .parent .task_spec , BoundaryEventSplit ):
222
- task = task .parent
223
- run_task_at_end = True # we jumped up one level, so exectute so we are on the correct task as requested.
224
-
225
- descendants = []
226
220
# Since recursive deletion of subprocesses requires access to the tasks, we have to delete any subprocesses first
227
221
# We also need diffeent behavior for the case where we explictly reset to a subprocess (in which case we delete it)
228
222
# vs resetting inside (where we leave it and reset the tasks that descend from it)
229
- for item in task :
230
- if item == task and not remove_subprocess :
231
- continue
232
- if item .id in self .subprocesses :
233
- descendants .extend (self .delete_subprocess (item ))
234
- descendants .extend (super ().reset_from_task_id (task .id , data ))
223
+ descendants = []
224
+
225
+ # If we're resetting to a boundary event, we also have to delete subprocesses underneath the attached events
226
+ top = task if not isinstance (task .parent .task_spec , BoundaryEventSplit ) else task .parent
227
+ for desc in filter (lambda t : t .id in self .subprocesses , top ):
228
+ if desc != task or remove_subprocess :
229
+ descendants .extend (self .delete_subprocess (desc ))
230
+
231
+ # This resets the boundary event branches
232
+ if isinstance (task .parent .task_spec , BoundaryEventSplit ):
233
+ for child in task .parent .children :
234
+ descendants .extend (super ().reset_from_task_id (child .id , data if child == task else None ))
235
+ else :
236
+ descendants .extend (super ().reset_from_task_id (task .id , data ))
235
237
236
238
if task .workflow .parent_task_id is not None :
237
239
sp_task = self .get_task_from_id (task .workflow .parent_task_id )
238
240
descendants .extend (self .reset_from_task_id (sp_task .id , remove_subprocess = False ))
239
- sp_task ._set_state (TaskState .WAITING )
240
-
241
- if run_task_at_end :
242
- task .run ()
241
+ sp_task ._set_state (TaskState .STARTED )
243
242
244
243
return descendants
245
244
0 commit comments