-
Notifications
You must be signed in to change notification settings - Fork 903
Shutting down a grpcsender without interrupting the thread #7557
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Oops, something went wrong.
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.
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.
do you know if the executor is using daemon threads, or do we need to worry about this possibly impacting application shutdown?
Uh oh!
There was an error while loading. Please reload this page.
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.
So
managedExecutor
is only true if noExecutorService
is NOT passed into this class, which means we are purging theExecutorService
only when we are usingOktHttp
defaultExecutorService
for theDispatcher
.Shouldn't it be the other way around, i.e. we only explicitly shut down the executor if we pass it in ourselves, and leave the clean up to
OkHttp
if it's providing its own executor?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 think we never use okhttp's default service, as we set one here when users don't provide any.
We are using daemon threads, but it's not guaranteed that it will always be the case. I didn't think of the app not closing due to a non-daemon thread scenario, because Android will still close an app regardless of existing non-daemon threads running, but it's a great point. Also, @laurit mentioned below that we're using
shutdownNow
in many places, so this doesn't seem to be a proper fix overall. I'll work on an alternative.Uh oh!
There was an error while loading. Please reload this page.
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.
LOL, sorry, I flipped the logic yesterday. What I meant to say is that
managedExecutor
is only true if you DON'T pass in an executor, so this codepath should never be hit if we always passed one in.THAT was the logic that I thought seems a bit off.
That being said, handing the uncaught exception explicitly seems like a good idea. Android won't crash the app until the uncaught exception is thrown on the main thread, but silently crashing a background thread isn't great either if you can deal with it explicitly.