There is a race between RyuApp instantiation and starting its thread.
In order to mitigate a race, split RyuApp initialization into creation of
instance and starting thread.
Introduce RyuApp.start() method to start threads.

Signed-off-by: Isaku Yamahata <[email protected]>
---
 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


------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire 
the most talented Cisco Certified professionals. Visit the 
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to