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.
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
Handle failure during thread creation #2471
Handle failure during thread creation #2471
Changes from 5 commits
58568fd
a24a1c4
60b5e32
7b03304
1392666
25b87a6
807f09f
30bf13a
842950f
3dcec2a
d4302a4
02efaca
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
I find it slightly confusing here that the method is called
ensure_running
, but it is possible for the method to terminate without the thread running. We should have some way to indicate failure, perhaps by raising a custom exception whenensure_running
cannot start the scheduler or by returning a value to indicate success/failure. We might instead or additionally consider renaming the function to indicate that we may fail to ensure that the scheduler is running and/or add a documentation comment.If we make this change to indicate when the
ensure_running
fails, we should also make sure to handle failure appropriately in the calling code.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.
@szokeasaurusrex Added docstrings to the three
ensure_running
functions.I considered making the function return a bool, but in all three cases it already communicates success/failure by setting the
self.(_)running
variable, so it feels a bit redundant to make it return essentially the same information, especially since the calling places usually can't do much with the return value -- all code that depends onensure_running
being run checks the value ofself.(_)running
instead anyway. Which feels like an ok pattern to me.Regarding the other points: