Closed kangz12345 closed 9 months ago
We observe this strange situation because the two modules are importing each other, i.e., cyclic or circular import. Python uses linear importing system, so there must not exist cyclic import.
Previously, we were doing cyclic import since qiwis
imports the app modules just when creating the app object, so there was no cyclic reference that might occur any conflict (unless the app module illegally uses qiwis
features to make such conflicts).
However, the global constant namespace introduced a shared variable across the qiwis
and app modules, which induces conflicts because of the cyclic imports.
Two resolve this, as @BECATRUE suggested, I will manually set each app's class attribute _constants
when instantiate it.
Reported by @BECATRUE.
As the original post shows, the global constant namespace becomes empty in other modules. The reason seems to be the importing process when creating the apps. The global constant namespace is initialized in
qiwis
module, i.e.,qiwis.BaseApp
. However, the apps defined in other modules importqiwis.BaseApp
and it seems the importedBaseApp
class obejct and the originalBaseApp
class object which resides inqiwis
module are two distinct class objects, so they do not share their namespace. In other words, the other modules which importqiwis
cannot see the changes made inBaseApp
class inqiwis
module (and vice versa).Not yet decided how to resolve this.
Original post:
The
config.json
for test is as follows:I printed the following two properties.
constants_
inmain()
(qiwis.py)self.constants
(numgen.py)Originally posted by @BECATRUE in https://github.com/snu-quiqcl/qiwis/issues/186#issuecomment-1707266627