Signed-off-by: YAMAMOTO Takashi <[email protected]>
---
 ryu/utils.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/ryu/utils.py b/ryu/utils.py
index e8fc7a2..1e1aa49 100644
--- a/ryu/utils.py
+++ b/ryu/utils.py
@@ -47,8 +47,12 @@ def chop_py_suffix(p):
 
 
 def _likely_same(a, b):
-    if os.path.samefile(a, b):
-        return True
+    try:
+        if os.path.samefile(a, b):
+            return True
+    except OSError:
+        # m.__file__ is not always accessible.  eg. egg
+        return False
     if chop_py_suffix(a) == chop_py_suffix(b):
         return True
     return False
@@ -57,6 +61,8 @@ def _likely_same(a, b):
 def _find_loaded_module(modpath):
     # copy() to avoid RuntimeError: dictionary changed size during iteration
     for k, m in sys.modules.copy().iteritems():
+        if k == '__main__':
+            continue
         if not hasattr(m, '__file__'):
             continue
         if _likely_same(m.__file__, modpath):
-- 
1.8.3.1


------------------------------------------------------------------------------
How ServiceNow helps IT people transform IT departments:
1. Consolidate legacy IT systems to a single system of record for IT
2. Standardize and globalize service processes across IT
3. Implement zero-touch automation to replace manual, redundant tasks
http://pubads.g.doubleclick.net/gampad/clk?id=51271111&iu=/4140/ostg.clktrk
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to