From 0f899f34ff19e3b5fd8f9bf524387b9df2f0c82a Mon Sep 17 00:00:00 2001 From: David Wilson Date: Mon, 12 Feb 2018 12:41:26 +0545 Subject: [PATCH] importer: new format to signal ImportError Previously we'd send just None in GET_MODULE reply, but now since there is no single request-reply structure, we must include the fullname in the LOAD_MODULE response and make all of its data fields None to indicate the same. --- mitogen/core.py | 2 +- mitogen/master.py | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/mitogen/core.py b/mitogen/core.py index 111b23e3..93adaf35 100644 --- a/mitogen/core.py +++ b/mitogen/core.py @@ -520,7 +520,7 @@ class Importer(object): event.wait() ret = self._cache[fullname] - if ret is None: + if ret[2] is None: raise ImportError('Master does not have %r' % (fullname,)) pkg_present = ret[1] diff --git a/mitogen/master.py b/mitogen/master.py index e24cbea5..e2deca90 100644 --- a/mitogen/master.py +++ b/mitogen/master.py @@ -635,6 +635,12 @@ class ModuleResponder(object): return self._cache[fullname] path, source, is_pkg = self._finder.get_module_source(fullname) + if source is None: + LOG.error('_build_tuple(%r): could not locate source', fullname) + tup = fullname, None, None, None, None + self._cache[fullname] = tup + return tup + if source is None: raise ImportError('could not find %r' % (fullname,)) @@ -675,8 +681,7 @@ class ModuleResponder(object): try: tup = self._build_tuple(fullname) - - for name in tup[4]: # related + for name in tup[4] or (): # related if name == fullname: # Must be sent last continue