This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author sangongs
Recipients sangongs
Date 2018-07-13.18:40:07
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1531507208.03.0.56676864532.issue34110@psf.upfronthosting.co.za>
In-reply-to
Content
If two threads use cPickle to load objects simultaneously, one thread may raise an AttributeError. This problem is caused by the partially loaded module.

To reproduce, create a file 'foo.py':
import time
time.sleep(0.1)
class foo():
    pass

Then in main.py:
import threading
import cPickle 

threads = [threading.Thread(target=cPickle.loads, args=('cfoo\nfoo\np0\n.',)) for _ in range(2)]
[thread.start() for thread in threads]
[thread.join() for thread in threads]

Run main.py, there should be a crash:
Exception in thread Thread-2:
Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 810, in __bootstrap_inner
    self.run()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 763, in run
    self.__target(*self.__args, **self.__kwargs)
AttributeError: 'module' object has no attribute 'foo'
History
Date User Action Args
2018-07-13 18:40:08sangongssetrecipients: + sangongs
2018-07-13 18:40:08sangongssetmessageid: <1531507208.03.0.56676864532.issue34110@psf.upfronthosting.co.za>
2018-07-13 18:40:07sangongslinkissue34110 messages
2018-07-13 18:40:07sangongscreate