handler: Fix for frozen builds

Navigates back the stack to locate the module instead of relying on
inspect to locate the module based on the file name.

This patch is suggested by papostolescu as Pull Request(*1)
on GitHub.
   (*1) https://github.com/osrg/ryu/pull/26

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
Iwase Yusuke 2016-08-23 14:07:25 +09:00 committed by FUJITA Tomonori
parent 37df91f7f4
commit db0f6c1165
1 changed files with 3 additions and 2 deletions

View File

@ -148,6 +148,7 @@ def register_service(service):
This mechanism is used to e.g. automatically start ofp_handler if
there are applications consuming OFP events.
"""
frm = inspect.stack()[1]
m = inspect.getmodule(frm[0])
frame = inspect.currentframe()
m_name = frame.f_back.f_globals['__name__']
m = sys.modules[m_name]
m._SERVICE_NAME = service