eric6/DebugClients/Python/ModuleLoader.py

branch
multi_processing
changeset 7407
a0b6acee2c20
parent 7404
663f1c3d6f53
child 7408
0d58e708f57b
equal deleted inserted replaced
7405:bf6be3cff6cf 7407:a0b6acee2c20
7 Module implementing an import hook patching modules to support debugging. 7 Module implementing an import hook patching modules to support debugging.
8 """ 8 """
9 9
10 import sys 10 import sys
11 import importlib 11 import importlib
12
13 from QProcessExtension import patchQProcess
12 14
13 15
14 class ModuleLoader(object): 16 class ModuleLoader(object):
15 """ 17 """
16 Class implementing an import hook patching modules to support debugging. 18 Class implementing an import hook patching modules to support debugging.
36 for moduleName in ("thread", "_thread", "threading"): 38 for moduleName in ("thread", "_thread", "threading"):
37 if moduleName in sys.modules: 39 if moduleName in sys.modules:
38 del sys.modules[moduleName] 40 del sys.modules[moduleName]
39 41
40 self.__modulesToPatch = ( 42 self.__modulesToPatch = (
41 'thread', '_thread', 'threading', 43 'thread', '_thread', 'threading',
42 'greenlet', 44 'greenlet',
43 'PyQt4.QtCore', 'PyQt5.QtCore', 45 'PyQt4.QtCore', 'PyQt5.QtCore',
44 'PySide.QtCore', 'PySide2.QtCore', 46 'PySide.QtCore', 'PySide2.QtCore',
45 ) 47 )
46 48
47 sys.meta_path.insert(0, self) 49 sys.meta_path.insert(0, self)
48 50
49 def __loadModule(self, fullname): 51 def __loadModule(self, fullname):
50 """ 52 """
51 Public method to load a module. 53 Private method to load a module.
52 54
53 @param fullname name of the module to be loaded 55 @param fullname name of the module to be loaded
54 @type str 56 @type str
55 @return reference to the loaded module 57 @return reference to the loaded module
56 @rtype module 58 @rtype module
80 not hasattr(module, 'eric6_patched') 82 not hasattr(module, 'eric6_patched')
81 ): 83 ):
82 if self.__dbgClient.patchGreenlet(module): 84 if self.__dbgClient.patchGreenlet(module):
83 module.eric6_patched = True 85 module.eric6_patched = True
84 86
85 ## Add hook for *.QThread 87 ## Add hook for *.QThread and *.QProcess
86 elif ( 88 elif (
87 fullname in ('PyQt4.QtCore', 'PyQt5.QtCore', 89 fullname in ('PyQt4.QtCore', 'PyQt5.QtCore',
88 'PySide.QtCore', 'PySide2.QtCore') and 90 'PySide.QtCore', 'PySide2.QtCore') and
89 not hasattr(module, 'eric6_patched') 91 not hasattr(module, 'eric6_patched')
90 ): 92 ):
91 module.eric6_patched = True 93 module.eric6_patched = True
92 self.__dbgClient.patchQThread(module) 94 self.__dbgClient.patchQThread(module)
95 patchQProcess(module, self.__dbgClient.startOptions)
93 96
94 self.__enableImportHooks = True 97 self.__enableImportHooks = True
95 return module 98 return module
96 99
97 if sys.version_info >= (3, 4): 100 if sys.version_info >= (3, 4):
133 """ 136 """
134 return self.__loadModule(spec.name) 137 return self.__loadModule(spec.name)
135 138
136 def exec_module(self, module): 139 def exec_module(self, module):
137 """ 140 """
138 Public method to execute the created module 141 Public method to execute the created module.
139 142
140 @param module module to be executed 143 @param module module to be executed
141 @type module 144 @type module
142 """ 145 """
143 pass 146 pass

eric ide

mercurial