New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Race condition during pickle.load() #80954
Comments
There seems to be a race condition when unpickling the same object from different threads (My guess is it's related to imports that are related to the unpickled object). I have used the following files for reproduction (File contents are in the attached archive, also pasted at the bottom of the issue report): I have used the files in the attached archive (containing the 3 files mentioned above) to reproduce run the following commands: pickle_object.py Running trigger.py will crash on about 50% of the runs with the following error: Traceback (most recent call last):
File "./trigger.py", line 16, in pickle_load_thread
pickle.load(h)
AttributeError: Can't get attribute 'PickleMe' on <module 'import_me' from '/data/import_me.py'> I have tested this on the following software stacks:
I'm uncertain if this is a bug related to pickle or python module importing. --------------------------------------------------------------------------------------- class PickleMe(object):
def __init__(self):
self.a = "a" filename: pickle_object.py import pickle
from import_me import PickleMe
p = PickleMe()
with open('pickled', 'wb') as h:
pickle.dump(p, h) filename: trigger.py import threading
import pickle
import logging
threads = []
def pickle_load_thread():
logging.error("Thread %d loading", threading.get_ident())
def start_pickle_load_thread():
for x in range(2):
load_thread = threading.Thread(target=pickle_load_thread)
load_thread.daemon = True
threads.append(load_thread)
for x in threads:
x.start()
if __name__ == '__main__':
start_pickle_load_thread()
for t in threads:
t.join() |
This could be a duplicate of bpo-34572 |
In what version should this be fixed? I see https://bugs.python.org/issue34572 says the fix is in version 3.7, while I'm experiencing this on python 3.7.3, which version should I check? |
It should be fixed in 3.7.3. https://docs.python.org/3.7/whatsnew/changelog.html#python-3-7-3-release-candidate-1 |
On Windows 10, this reproduces consistently with 3.6 and 3.7.0, but not with 3.7.4, 3.8.0b3 and current master. So this definitely seems to be fixed. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: