mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 08:24:40 +01:00
fixes to background module importer
This commit is contained in:
parent
19496d9247
commit
e0830edf93
3 changed files with 9 additions and 6 deletions
|
@ -187,7 +187,8 @@ class BackgroundModuleProxy(types.ModuleType):
|
|||
}
|
||||
|
||||
def __getattribute__(self, name):
|
||||
if name == '__dct__':
|
||||
passthrough = frozenset({'__dct__','__class__', '__spec__'})
|
||||
if name in passthrough:
|
||||
return super().__getattribute__(name)
|
||||
dct = self.__dct__
|
||||
modname = dct['modname']
|
||||
|
@ -224,7 +225,7 @@ class BackgroundModuleLoader(threading.Thread):
|
|||
i += 1
|
||||
# now import pkg_resources properly
|
||||
modname = importlib.util.resolve_name(self.name, self.package)
|
||||
if isinstance(sys.modules[modname], PkgResourcesProxy):
|
||||
if isinstance(sys.modules[modname], BackgroundModuleProxy):
|
||||
del sys.modules[modname]
|
||||
mod = importlib.import_module(self.name, package=self.package)
|
||||
for targname, varname in self.replacements.items():
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# must come before ptk / pygments imports
|
||||
from xonsh.bg_pkg_resources import load_pkg_resources_in_background
|
||||
load_pkg_resources_in_background()
|
||||
from xonsh.lazyasd import load_module_in_background
|
||||
load_module_in_background('pkg_resources', debug='XONSH_DEBUG',
|
||||
replacements={'pygments.plugin': 'pkg_resources'})
|
||||
|
|
|
@ -10,8 +10,9 @@ from collections import ChainMap
|
|||
from collections.abc import MutableMapping
|
||||
|
||||
# must come before pygments imports
|
||||
from xonsh.bg_pkg_resources import load_pkg_resources_in_background
|
||||
load_pkg_resources_in_background()
|
||||
from xonsh.lazyasd import load_module_in_background
|
||||
load_module_in_background('pkg_resources', debug='XONSH_DEBUG',
|
||||
replacements={'pygments.plugin': 'pkg_resources'})
|
||||
|
||||
from pygments.lexer import inherit, bygroups, using, this
|
||||
from pygments.lexers.shell import BashLexer
|
||||
|
|
Loading…
Add table
Reference in a new issue