Message141549
OK, digging deeper reveals that there are actually two bugs here, one is conceptual in the python importing mechanism, and the other is technical in cPickle.
The first bug:
PyImport_ExecCodeModuleEx adds the module to sys.modules *before* actually executing the code. This is a design flaw (can it really be changed? )
Demonstrating this bug is easy using the foo.py module from the previous comment:
def f():
if 'bla' in sys.modules:
bla = sys.modules['bla']
else:
import bla
return bla.A()
running two instances of f in two threads results in the same error.
The second bug: in cPickle.c: func_class()
cPickle 'manually' checks if a module is in sys.modules instead of letting the import mechanism do it for him (hence breaking the import lock's defense here). |
|
Date |
User |
Action |
Args |
2011-08-02 08:48:36 | Sagiv.Malihi | set | recipients:
+ Sagiv.Malihi |
2011-08-02 08:48:35 | Sagiv.Malihi | set | messageid: <1312274915.97.0.144720506946.issue12680@psf.upfronthosting.co.za> |
2011-08-02 08:48:35 | Sagiv.Malihi | link | issue12680 messages |
2011-08-02 08:48:34 | Sagiv.Malihi | create | |
|