don't load RyuApps which is just imported and not defined in the module.
for example, if we run the script "test.py" as shown below by

$ ryu run test.py

the past implementation loads and instantiates not only Test but also RyuApp
and DPSet. this patch fix this wrong behavior

test.py
===

from ryu.base.app_manager import RyuApp
from ryu.controller.dpset import DPSet

class Test(RyuApp):
    _CONTEXTS = {'dpset' : DPSet}

Signed-off-by: ISHIDA Wataru <[email protected]>
---
 ryu/base/app_manager.py |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/ryu/base/app_manager.py b/ryu/base/app_manager.py
index 695c401..357d34d 100644
--- a/ryu/base/app_manager.py
+++ b/ryu/base/app_manager.py
@@ -27,6 +27,7 @@ import inspect
 import itertools
 import logging
 import sys
+import os

 from ryu import cfg
 from ryu import utils
@@ -338,8 +339,11 @@ class AppManager(object):

     def load_app(self, name):
         mod = utils.import_module(name)
-        clses = inspect.getmembers(mod, lambda cls: (inspect.isclass(cls) and
-                                                     issubclass(cls, RyuApp)))
+        clses = inspect.getmembers(mod,
+                                   lambda cls: (inspect.isclass(cls) and
+                                                issubclass(cls, RyuApp) and
+                                                mod.__name__ ==
+                                                cls.__module__))
         if clses:
             return clses[0][1]
         return None
-- 
1.7.10.4




------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to