From 81dd265c2028bb0ddba7ef094a8cd6ce009392aa Mon Sep 17 00:00:00 2001 From: David Wilson Date: Fri, 19 Aug 2016 11:01:45 +0100 Subject: [PATCH] Catch BaseException to cope with KeyboardInterrupt and suchlike. Django's module autoreloader calls sys.exit(), we want to catch that. --- econtext/core.py | 2 +- econtext/master.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/econtext/core.py b/econtext/core.py index 0e57f91d..35821505 100644 --- a/econtext/core.py +++ b/econtext/core.py @@ -856,7 +856,7 @@ class ExternalContext(object): self.broker.register(self.context) self._dispatch_calls() LOG.debug('ExternalContext.main() normal exit') - except Exception: + except BaseException: LOG.exception('ExternalContext.main() crashed') raise finally: diff --git a/econtext/master.py b/econtext/master.py index 9bb3f11b..6eee353f 100644 --- a/econtext/master.py +++ b/econtext/master.py @@ -156,8 +156,9 @@ class ModuleResponder(object): pkg_path = os.path.dirname(pkg.__file__) try: fp, path, ext = imp.find_module(modname, [pkg_path]) + LOG.error('%r', (fp, path, ext)) return path, fp.read(), False - except ImportError: + except ImportError, e: LOG.debug('imp.find_module(%r, %r) -> %s', modname, [pkg_path], e) get_module_methods = [_get_module_via_pkgutil,