Merge pull request #281 from dw/issue280

Issue280
pull/283/head
dw 7 years ago committed by GitHub
commit 29262a6000
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -290,15 +290,26 @@ class NewStylePlanner(ScriptPlanner):
def get_module_deps(self): def get_module_deps(self):
return self.get_module_map()['builtin'] return self.get_module_map()['builtin']
#: Module names appearing in this set always require forking, usually due
#: to some terminal leakage that cannot be worked around in any sane
#: manner.
ALWAYS_FORK_MODULES = frozenset([
'dnf', # issue #280; py-dnf/hawkey need therapy
])
def should_fork(self): def should_fork(self):
""" """
In addition to asynchronous tasks, new-style modules should be forked In addition to asynchronous tasks, new-style modules should be forked
if the user specifies mitogen_task_isolation=fork, or if the new-style if:
module has a custom module search path.
* the user specifies mitogen_task_isolation=fork, or
* the new-style module has a custom module search path, or
* the module is known to leak like a sieve.
""" """
return ( return (
super(NewStylePlanner, self).should_fork() or super(NewStylePlanner, self).should_fork() or
(self._inv.task_vars.get('mitogen_task_isolation') == 'fork') or (self._inv.task_vars.get('mitogen_task_isolation') == 'fork') or
(self._inv.module_name in self.ALWAYS_FORK_MODULES) or
(len(self.get_module_map()['custom']) > 0) (len(self.get_module_map()['custom']) > 0)
) )

@ -623,7 +623,7 @@ class Importer(object):
fullname = fullname.rstrip('.') fullname = fullname.rstrip('.')
try: try:
pkgname, dot, _ = fullname.rpartition('.') pkgname, dot, _ = fullname.rpartition('.')
_v and LOG.debug('%r.find_module(%r)', self, fullname) _vv and IOLOG.debug('%r.find_module(%r)', self, fullname)
suffix = fullname[len(pkgname+dot):] suffix = fullname[len(pkgname+dot):]
if suffix not in self._present.get(pkgname, (suffix,)): if suffix not in self._present.get(pkgname, (suffix,)):
_v and LOG.debug('%r: master doesn\'t know %r', self, fullname) _v and LOG.debug('%r: master doesn\'t know %r', self, fullname)
@ -631,8 +631,10 @@ class Importer(object):
pkg = sys.modules.get(pkgname) pkg = sys.modules.get(pkgname)
if pkg and getattr(pkg, '__loader__', None) is not self: if pkg and getattr(pkg, '__loader__', None) is not self:
_v and LOG.debug('%r: %r is submodule of a package we did not load', _vv and IOLOG.debug(
self, fullname) '%r: %r is submodule of a package we did not load',
self, fullname
)
return None return None
# #114: explicitly whitelisted prefixes override any # #114: explicitly whitelisted prefixes override any
@ -643,9 +645,10 @@ class Importer(object):
try: try:
self.builtin_find_module(fullname) self.builtin_find_module(fullname)
_v and LOG.debug('%r: %r is available locally', self, fullname) _vv and IOLOG.debug('%r: %r is available locally',
self, fullname)
except ImportError: except ImportError:
_v and LOG.debug('find_module(%r) returning self', fullname) _vv and IOLOG.debug('find_module(%r) returning self', fullname)
return self return self
finally: finally:
del _tls.running del _tls.running

Loading…
Cancel
Save