Closed nforro closed 1 year ago
this is magic
The trick with the global variable to prevent repeated initialization comes from the documentation: https://docs.python.org/3/library/importlib.html#importlib.reload
The fact that importlib.reload()
does nothing when called recursively isn't documented anywhere, but it's the only reason the initial implementation worked without ending up with infinite recursion :slightly_smiling_face:
Zuul is still not enabled for this project, merging manually.
When the shim module tries to reload itself, it repeats the loop of trying all the sitepackages directories, and because
importlib.reload()
is noop when called recursively, it ends up raisingImportError
that is visible to the user. Even though execution returns to the original loop and the system RPM module is loaded successfully, the error message produced is very confusing.Improve that by avoiding repeated initialization of the shim module. Also make sure that
importlib.reload()
, when loading the shim module for the second time, throws a specific exception that doesn't trigger any log message, to make things even less confusing.