On 04/27/2010 04:32 PM, clumens@xxxxxxxxxx wrote:
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.
Let's start by moving code that shouldn't be run more than once into
functions and classes to ensure it only runs once. Now that anaconda's
a module, it should act like a well-behaved module and not totally crap
out just because it was imported twice.
After we do that, let's see where we stand.
I've just proposed a patch that should fix the 'everything logged twice'
bug by introducing an init() method to anacodna_log that has to be
called manually sometime during anaconda startup.
Note that there are still issues with double import: if the init()
initializes a global module variable (singleton, like
anaconda_log.logger), this will always stay uninitialized for all the
code that imports 'the other' same module (pyanaconda.anaconda_log) as
it has its own copies of all the module global variables. At the same
time calling init() twice would
a) look weird,
b) bring us back to the original problem because it would make all the
side-effects of the initialization happen twice.
Ales
_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list