Skip to content
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

bpo-31070: Fix a race condition in importlib _get_module_lock(). #3033

Merged

Conversation

serhiy-storchaka
Copy link
Member

@serhiy-storchaka serhiy-storchaka commented Aug 9, 2017

Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I just suggest to add a comment.

def cb(ref, name=name):
_imp.acquire_lock()
try:
if _module_locks.get(name) is ref:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest to add a comment on the test. Something like:

# bpo-31070: Check if another thread created a new lock
# after the previous lock was destroyed
# but before the weakref callback was called

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the comment.

Copy link
Contributor

@ncoghlan ncoghlan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@serhiy-storchaka serhiy-storchaka merged commit 9b0d1d6 into python:master Aug 9, 2017
@serhiy-storchaka serhiy-storchaka deleted the import-module-lock-callback branch August 9, 2017 11:29
serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this pull request Aug 9, 2017
@bedevere-bot
Copy link

GH-3038 is a backport of this pull request to the 3.6 branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants