Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

bpo-31783: Fix a race condition creating workers during shutdown#13171

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
brianquinlan merged 4 commits intopython:masterfrombrianquinlan:shutdown-race
Jun 28, 2019

Conversation

brianquinlan
Copy link
Contributor

@brianquinlanbrianquinlan commentedMay 7, 2019
edited by bedevere-bot
Loading

@markshannon
Copy link
Member

Can you add a test for this, thanks.

@brianquinlan
Copy link
ContributorAuthor

brianquinlan commentedMay 8, 2019
edited
Loading

The race condition occurs with the following set of context switches:

Main Thread                           Thread  #1========= .                         ========1.                                   ThreadPoolExecutor.submit()                                        ...                                        if _shutdown:                    <=====2. thread._python_exit      _shutdown = true      items = list(_threads_queues.items())                    =====>3.                                      ...                                         _threads_queues[t] = self._work_queue                    <=====4.     for t, q in items:        q.put(None)    for t, q in items:        t.join()

At this point there is a new thread added to_threads_queues butthread._python_exit won'tjoin it because it was added to_threads_queuesafter a copy was made (i.e.
items = list(_threads_queues.items()))

The bug has a patch withtime.sleep() to force the pathological sequencing and a test script to demonstrate the problem.

@brianquinlan
Copy link
ContributorAuthor

I don't think writing a test for this would be feasible because provoking the race condition requires very specific timing that, at least on my machine, I can't provoke without addingsleep calls to the code.

@brianquinlanbrianquinlan merged commit242c26f intopython:masterJun 28, 2019
@bedevere-bot
Copy link

@brianquinlan: Please replace# withGH- in the commit message next time. Thanks!

@miss-islington
Copy link
Contributor

Thanks@brianquinlan for the PR 🌮🎉.. I'm working now to backport this PR to: 3.7.
🐍🍒⛏🤖

@miss-islington
Copy link
Contributor

Thanks@brianquinlan for the PR 🌮🎉.. I'm working now to backport this PR to: 3.8.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

@miss-islington
Copy link
Contributor

Sorry,@brianquinlan, I could not cleanly backport this to3.8 due to a conflict.
Please backport usingcherry_picker on command line.
cherry_picker 242c26f53edb965e9808dd918089e664c0223407 3.8

@miss-islington
Copy link
Contributor

Sorry@brianquinlan, I had trouble checking out the3.7 backport branch.
Please backport usingcherry_picker on command line.
cherry_picker 242c26f53edb965e9808dd918089e664c0223407 3.7

lisroach pushed a commit to lisroach/cpython that referenced this pull requestSep 10, 2019
…hon#13171)* bpo-31783: Fix a race condition while creating workers during interpreter shutdown* 📜🤖 Added by blurb_it.
DinoV pushed a commit to DinoV/cpython that referenced this pull requestJan 14, 2020
…hon#13171)* bpo-31783: Fix a race condition while creating workers during interpreter shutdown* 📜🤖 Added by blurb_it.
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees

@brianquinlanbrianquinlan

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

5 participants
@brianquinlan@markshannon@bedevere-bot@miss-islington@the-knights-who-say-ni

[8]ページ先頭

©2009-2025 Movatter.jp