浏览代码

Fix problem with race condition in addInput on threads platform

Yentl Van Tendeloo 8 年之前
父节点
当前提交
264b048928
共有 1 个文件被更改,包括 5 次插入1 次删除
  1. 5 1
      src/python_sccd/python_sccd_runtime/statecharts_core.py

+ 5 - 1
src/python_sccd/python_sccd_runtime/statecharts_core.py

@@ -654,7 +654,11 @@ class ThreadsControllerBase(ControllerBase):
                     print '\r' + ' ' * 80,
                     self.behind = False
                 with self.input_condition:
-                    self.input_condition.wait((earliest_event_time - now) / 1000.0)
+                    if earliest_event_time == self.getEarliestEventTime():
+                        self.input_condition.wait((earliest_event_time - now) / 1000.0)
+                    else:
+                        # Something happened that made the queue fill up already, but we were not yet waiting for the Condition...
+                        pass
             else:
                 if now - earliest_event_time > 10 and now - self.last_print_time >= 1000:
                     if self.behind_schedule_callback: