- # print("deleting tasks", topic, _id, op_id, self.task_registry[topic][_id][op_id])
- del self.task_registry[topic][_id][op_id]
- elif task_name in self.task_registry[topic][_id][op_id]:
- # print("deleting tasks", topic, _id, op_id, task_name, self.task_registry[topic][_id][op_id][task_name])
- del self.task_registry[topic][_id][op_id][task_name]
- if not self.task_registry[topic][_id][op_id]:
- del self.task_registry[topic][_id][op_id]
+ self.task_registry[topic][_id].pop(op_id, None)
+ elif self.task_registry[topic][_id].get(op_id):
+ self.task_registry[topic][_id][op_id].pop(task_name, None)
+
+ # delete done tasks
+ for op_id_ in list(self.task_registry[topic][_id]):
+ for name, task in self.task_registry[topic][_id][op_id_].items():
+ if not task.done():
+ break
+ else:
+ del self.task_registry[topic][_id][op_id_]