There is a race between RyuApp instantiation and starting its thread. Each RyuApp spawns an event-loop thread which handles events and may generate events when a RyuApp instance is created. Currently on startup, necessary RyuApps are created, and event-loop thread is created at the same time. Then event-piping (which events are delivered to which RyuApp) is done. This causes missing events if RyuApp which was create early generates events before finishing event-piping.
To address it, split RyuApp startup into three phases from two phase. - create RyuApp instances - event piping - then, start event-loop threads. Signed-off-by: Isaku Yamahata <yamah...@valinux.co.jp> --- Changes v1 -> v2: - improve commit message --- ryu/base/app_manager.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ryu/base/app_manager.py b/ryu/base/app_manager.py index 53419cf..0112aab 100644 --- a/ryu/base/app_manager.py +++ b/ryu/base/app_manager.py @@ -65,6 +65,11 @@ class RyuApp(object): self.events = Queue() self.replies = Queue() self.logger = logging.getLogger(self.name) + + def start(self): + """ + Hook that is called after startup initialization is done. + """ self.threads.append(gevent.spawn(self._event_loop)) def register_handler(self, ev_cls, handler): @@ -229,6 +234,9 @@ class AppManager(object): for ev_cls in i.event_handlers.keys(): LOG.debug(" CONSUMES %s" % (ev_cls.__name__,)) + for app in self.applications.values(): + app.start() + def close(self): def close_all(close_dict): for app in close_dict.values(): -- 1.7.10.4 ------------------------------------------------------------------------------ Precog is a next-generation analytics platform capable of advanced analytics on semi-structured data. The platform includes APIs for building apps and a phenomenal toolset for data science. Developers can use our toolset for easy data analysis & visualization. Get a free account! http://www2.precog.com/precogplatform/slashdotnewsletter _______________________________________________ Ryu-devel mailing list Ryu-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ryu-devel