-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
gh-141617: Add missing result() call in concurrent.futures example #141620
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
base: main
Are you sure you want to change the base?
Conversation
picnixz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The other place where to add the comment was after b = executor.submit(wait_on_a) just a few lines above not in the documentation for submit.
Doc/library/concurrent.futures.rst
Outdated
| # Note: calling future.result() outside this with statement would work fine, | ||
| # but calling it here is safe because we print it immediately and the executor | ||
| # can complete the task before the context manager exits. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is incorrect. It's not for this example that we needed to add this comment.
Doc/library/concurrent.futures.rst
Outdated
| executor = ThreadPoolExecutor(max_workers=1) | ||
| executor.submit(wait_on_future) | ||
|
|
||
| executor.submit(wait_on_future).result() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not call .result(). We should indicate in the comment that calling .result would produce a deadlock.
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
|
I have made the requested changes; please review again |
|
Thanks for making the requested changes! @picnixz: please review the changes made to this pull request. |
|
Hi @picnixz Just checking in on this PR. I'm happy to address any remaining feedback or make changes as needed. Please let me know if there's anything I should update. Thanks. |
This PR fixes an incomplete code example in the concurrent.futures documentation.
The second example in the deadlock section was missing a
.result()call on the executor.submit() invocation, which is necessary to demonstrate the deadlock behavior described in the comment.Changes:
.result()call to complete the example in Doc/library/concurrent.futures.rstFixes #141617
📚 Documentation preview 📚: https://cpython-previews--141620.org.readthedocs.build/