mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #29065 from cachedout/issue_28810
Handle failures inside python's inspect if a module is reloaded
This commit is contained in:
commit
88c0354c0c
1 changed files with 15 additions and 8 deletions
|
@ -63,14 +63,21 @@ class Depends(object):
|
|||
and determine which module and function name it is to store in the
|
||||
class wide depandancy_dict
|
||||
'''
|
||||
frame = inspect.stack()[1][0]
|
||||
# due to missing *.py files under esky we cannot use inspect.getmodule
|
||||
# module name is something like salt.loaded.int.modules.test
|
||||
kind = frame.f_globals['__name__'].rsplit('.', 2)[1]
|
||||
for dep in self.dependencies:
|
||||
self.dependency_dict[kind][dep].add(
|
||||
(frame, function, self.fallback_function)
|
||||
)
|
||||
try:
|
||||
# This inspect call may fail under certain conditions in the loader. Possibly related to
|
||||
# a Python bug here:
|
||||
# http://bugs.python.org/issue17735
|
||||
frame = inspect.stack()[1][0]
|
||||
# due to missing *.py files under esky we cannot use inspect.getmodule
|
||||
# module name is something like salt.loaded.int.modules.test
|
||||
kind = frame.f_globals['__name__'].rsplit('.', 2)[1]
|
||||
for dep in self.dependencies:
|
||||
self.dependency_dict[kind][dep].add(
|
||||
(frame, function, self.fallback_function)
|
||||
)
|
||||
except Exception as exc:
|
||||
log.error('Exception encountered when attempting to inspect frame in '
|
||||
'dependency decorator: {0}'.format(exc))
|
||||
return function
|
||||
|
||||
@classmethod
|
||||
|
|
Loading…
Add table
Reference in a new issue