Throw an exception when we detect a complex circular dependency

This commit is contained in:
jesopo 2019-05-27 11:42:47 +01:00
parent 5b780672a8
commit ce3a0668c6

View file

@ -24,6 +24,8 @@ class ModuleDependencyNotFulfilled(ModuleException):
% (module, dependency))
self.module = module
self.dependency = dependency
class ModuleCircularDependency(ModuleException):
pass
class ModuleType(enum.Enum):
FILE = 0
@ -266,9 +268,12 @@ class ModuleManager(object):
self.log.warn(
"Circular dependencies detected: %s<->%s",
[name, dep_name])
changed = True
# snap a circular dependence
deps.remove(dep_name)
definition_dependencies[dep_name].remove(name)
if not changed:
raise ModuleCircularDependency()
return [definition_names[name] for name in definitions_ordered]