Skip to content

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

Merged
serhiy-storchaka merged 3 commits into
python:masterfrom
serhiy-storchaka:import-module-lock-callback
Aug 9, 2017
Merged

bpo-31070: Fix a race condition in importlib _get_module_lock().#3033
serhiy-storchaka merged 3 commits into
python:masterfrom
serhiy-storchaka:import-module-lock-callback

Conversation

@serhiy-storchaka

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

Copy link
Copy Markdown
Member

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
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
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done.

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

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.

@ncoghlan ncoghlan left a comment

Copy link
Copy Markdown
Contributor

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
Copy Markdown

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