New submission from Sagiv Malihi :
When trying to cPickle.loads() from several threads at once, there is a race
condition when threads try to import modules.
An example will explain it best:
suppose I have module foo.py which takes some time to load:
import time
class A(object):
def
Sagiv Malihi added the comment:
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
Sagiv Malihi added the comment:
As I said - it certainly happenes on 3.2 (tested).
@pitrou - what you suggested will not work since the actual import will block
on the import lock.
The optimization there is not needed, it's already implemented in __imp
Changes by Sagiv Malihi :
--
nosy: +Sagiv.Malihi
___
Python tracker
<http://bugs.python.org/issue8733>
___
___
Python-bugs-list mailing list
Unsubscribe:
Sagiv Malihi added the comment:
Example:
class A(object):
def __init__(self):
print "initializing something very important"
# and then pay it forward...
super(A, self).__init__()
class B(list, A): pass
b = B()
# A's init