summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--ryu/base/app_manager.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/ryu/base/app_manager.py b/ryu/base/app_manager.py
index 340d31a9..5b63e8cd 100644
--- a/ryu/base/app_manager.py
+++ b/ryu/base/app_manager.py
@@ -77,11 +77,12 @@ def require_app(app_name, api_style=False):
If this is used for client application module, set api_style=False.
"""
+ iterable = (inspect.getmodule(frame[0]) for frame in inspect.stack())
+ modules = [module for module in iterable if module is not None]
if api_style:
- frm = inspect.stack()[2] # skip a frame for "api" module
+ m = modules[2] # skip a frame for "api" module
else:
- frm = inspect.stack()[1]
- m = inspect.getmodule(frm[0]) # client module
+ m = modules[1]
m._REQUIRED_APP = getattr(m, '_REQUIRED_APP', [])
m._REQUIRED_APP.append(app_name)
LOG.debug('require_app: %s is required by %s', app_name, m.__name__)