[3.8] bpo-37193: remove thread objects which finished process its request (GH-13893)#23088
Closed
miss-islington wants to merge 1 commit intopython:3.8from
Closed
[3.8] bpo-37193: remove thread objects which finished process its request (GH-13893)#23088miss-islington wants to merge 1 commit intopython:3.8from
miss-islington wants to merge 1 commit intopython:3.8from
Conversation
…ythonGH-13893) * bpo-37193: remove the thread which finished process request from threads list * rename variable t to thread. * don't remove thread from list if it is daemon. * use lock to protect self._threads. * use finally block in case of exception from shutdown_request(). * check "not thread.daemon" before lock to avoid holding the lock if it's unnecessary. * fix the place of _threads_lock. * separate code to remove a current thread into a function. * check ValueError when removing thread. * fix wrong code which all instance shared same lock. * Extract thread management into a _Threads class to encapsulate atomic operations and separate concerns. * Replace multiple references of 'block_on_close' with one, avoiding the possibility that 'block_on_close' could change during the course of processing requests. Now, there's exactly one _threads object with behavior fixed for the duration. * Add docstrings to private classes. * Add test to ensure that a ThreadingTCPServer can be closed without serving any requests. * Use _NoThreads as the default value. Fixes AttributeError when server is closed without serving any requests. * Add blurb * Add test capturing failure. Co-authored-by: Jason R. Coombs <[email protected]> (cherry picked from commit c415590) Co-authored-by: MARUYAMA Norihiro <[email protected]>
Contributor
Author
1 similar comment
Contributor
Author
Contributor
Author
Member
|
I reject the backport since it causes a regression on master: https://bugs.python.org/issue37193#msg380172 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
bpo-37193: remove the thread which finished process request from threads list
rename variable t to thread.
don't remove thread from list if it is daemon.
use lock to protect self._threads.
use finally block in case of exception from shutdown_request().
check "not thread.daemon" before lock to avoid holding the lock if it's unnecessary.
fix the place of _threads_lock.
separate code to remove a current thread into a function.
check ValueError when removing thread.
fix wrong code which all instance shared same lock.
Extract thread management into a _Threads class to encapsulate atomic operations and separate concerns.
Replace multiple references of 'block_on_close' with one, avoiding the possibility that 'block_on_close' could change during the course of processing requests. Now, there's exactly one _threads object with behavior fixed for the duration.
Add docstrings to private classes.
Add test to ensure that a ThreadingTCPServer can be closed without serving any requests.
Use _NoThreads as the default value. Fixes AttributeError when server is closed without serving any requests.
Add blurb
Add test capturing failure.
Co-authored-by: Jason R. Coombs [email protected]
(cherry picked from commit c415590)
Co-authored-by: MARUYAMA Norihiro [email protected]
https://bugs.python.org/issue37193