瀏覽代碼

Try another update, where we ignore unexpected events

Yentl Van Tendeloo 7 年之前
父節點
當前提交
782b27baee
共有 1 個文件被更改,包括 28 次插入27 次删除
  1. 28 27
      model/model.py

+ 28 - 27
model/model.py

@@ -429,7 +429,6 @@ class ModelverseInterface(AtomicDEVS):
                     task_name, _ = prev_output.split(" : ", 1)
                     self.state.blocked = True
                     self.state.task_to_spawner[task_name] = None
-                    self.state.send_operations[task_name] = [[]]
                     # NOTE We now know that there is something to do on an other task, so we just wait for that event to come in
                     self.state.operations.insert(0, [])
                     self.state.operations.insert(0, [])
@@ -439,32 +438,34 @@ class ModelverseInterface(AtomicDEVS):
 
             elif inp[0] != self.taskname:
                 # Got some output on another task
-                self.state.send_operations[inp[0]].pop(0)
-
-                if inp[1].startswith("Please edit this model before sending next input: "):
-                    _, model_name = inp[1].split("Please edit this model before sending next input: ", 1)
-                    new_taskname = str(uuid.uuid4())
-                    self.state.send_operations[new_taskname] = [[], ["admin"], ["admin"], ["quiet"], ["model_modify", model_name, ""]] + self.state.keyed_operations.get(self.state.task_to_operation[inp[0]], []) + [["exit"]]
-                    print("Modifying model " + str(model_name))
-                    print("On taskname " + str(new_taskname))
-                    self.state.create_additional_task.append(new_taskname)
-                    self.state.task_to_spawner[new_taskname] = inp[0]
-                elif inp[1].startswith("Please perform manual operation "):
-                    _, op_name = inp[1].split("Please perform manual operation ", 1)
-                    self.state.task_to_operation[inp[0]] = op_name[1:-1]
-
-                if not self.state.send_operations[inp[0]]:
-                    del self.state.send_operations[inp[0]]
-
-                    # At the end of these operations, so finish up!
-                    if self.state.task_to_spawner[inp[0]] is not None:
-                        self.state.keyed_operations.pop(self.state.task_to_operation[self.state.task_to_spawner[inp[0]]], None)
-                        self.state.additional_operations.insert(0, [])
-                        self.state.send_operations[self.state.task_to_spawner[inp[0]]] = ["__continue__"]
-                    else:
-                        self.state.additional_operations.pop(0)
-                        self.state.operations.pop(0)
-                        print("Clear up to the normal task!")
+                # If the task is not registered yet, it is likely not important to communicate with it, so ignore it
+                if inp[0] in self.state.send_operations:
+                    self.state.send_operations[inp[0]].pop(0)
+
+                    if inp[1].startswith("Please edit this model before sending next input: "):
+                        _, model_name = inp[1].split("Please edit this model before sending next input: ", 1)
+                        new_taskname = str(uuid.uuid4())
+                        self.state.send_operations[new_taskname] = [[], ["admin"], ["admin"], ["quiet"], ["model_modify", model_name, ""]] + self.state.keyed_operations.get(self.state.task_to_operation[inp[0]], []) + [["exit"]]
+                        print("Modifying model " + str(model_name))
+                        print("On taskname " + str(new_taskname))
+                        self.state.create_additional_task.append(new_taskname)
+                        self.state.task_to_spawner[new_taskname] = inp[0]
+                    elif inp[1].startswith("Please perform manual operation "):
+                        _, op_name = inp[1].split("Please perform manual operation ", 1)
+                        self.state.task_to_operation[inp[0]] = op_name[1:-1]
+
+                    if not self.state.send_operations[inp[0]]:
+                        del self.state.send_operations[inp[0]]
+
+                        # At the end of these operations, so finish up!
+                        if self.state.task_to_spawner[inp[0]] is not None:
+                            self.state.keyed_operations.pop(self.state.task_to_operation[self.state.task_to_spawner[inp[0]]], None)
+                            self.state.additional_operations.insert(0, [])
+                            self.state.send_operations[self.state.task_to_spawner[inp[0]]] = ["__continue__"]
+                        else:
+                            self.state.additional_operations.pop(0)
+                            self.state.operations.pop(0)
+                            print("Clear up to the normal task!")
 
         return self.state