Hi Chris, list,
I think the whole 'pyanaconda' change had one side effect we didn't
expect: modules can be imported and initialized twice now.
The sys.path now contains both:
site-packages
site-packages/pyanaconda
The first one is the default and allows us to do things like
from pyanaconda import Anaconda
which we almost never do. The second one allows us to do the classical
short:
import kickstart
The problem is when you do
import module
and later:
from pyanaconda import module
For python, the two modules seem to be a different module and so it
loads them twice (and adds them as two separate entries into
sys.modules, once as 'module', then as 'pyanaconda.module'). The module
init code that we expect to be executed exactly once is then executed
twice. I found out about this thing by noticing that all the logging
output is doubled after certain execution point (due to handlers being
added twice). Another complication is with updates: if a module is first
imported from your update directory but later from
site-packages/pyanaconda, it actually runs a different code--->total chaos.
I spend the morning looking at this and here's what we could do:
1) Replace all imports to be from pyanaconda. instead of:
import kickstart
one would write:
from pyanaconda import kickstart
Big and tedious change.
2) have import hooks that make sure everything is imported only once.
Attempt to load an already imported module will produce a mere
entry/reference copy in sys.modules. I prefer this solution, it allows
us to gradually migrate to (1) and then get rid of it.
3) Remove all the offending
from pyanaconda import ..
lines and only use the old import style. This means the problem is going
to bite us later (or it's going to bite someone who imports anaconda
modules and then us).
Ales
_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list