Message321627
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' |
|
Date |
User |
Action |
Args |
2018-07-13 18:40:08 | sangongs | set | recipients:
+ sangongs |
2018-07-13 18:40:08 | sangongs | set | messageid: <1531507208.03.0.56676864532.issue34110@psf.upfronthosting.co.za> |
2018-07-13 18:40:07 | sangongs | link | issue34110 messages |
2018-07-13 18:40:07 | sangongs | create | |
|