-
Notifications
You must be signed in to change notification settings - Fork 27
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
Making the connection nsq-read threads daemon #87
base: main
Are you sure you want to change the base?
Conversation
Client::stop is how you shut everything down cleanly. Try replacing
with
|
That's more like a workaround, as it requires 30 seconds of waiting, while my PR does a different thing: it prevents any Pub/Sub instance from creating a background thread that's not running as a daemon one. Also, more in general, how come that I'm required to call |
@robseed your suggestion is to always keep a hold on a |
@mfirry There is no need to keep track of a client instance or pass it into the constructors, just call |
What if someone doesn't want to use the default client? |
The only reasons you might need more than one client are rare and specialized -- perhaps 2 independent teams at your company run 2 independent nsq clusters (say, one for metrics and another for sending email) and they are require different configurations (maybe one uses authentication and the other doesn't) Even if this PR was merged, under real scenarios you'd still need to call Client::stop to shut down cleanly because there is an Executor running the message handlers and another Executor for delayed operations. Maybe you could make those use thread factories that create daemon threads -- but I'd still prefer one specific method to stop cleanly. One could argue Publisher::stop and Subscriber::stop should not be public to avoid this confusion. |
This PR is about fixing a non daemon thread in the |
Sure, I guess it can't do any harm, but once again what you should do is call Client::stop |
I've noticed using the library that there is a dangling non daemon thread that keeps the app open even after closing all the resources created via the library.
I spotted where the dangling thread gets created and I've managed to make it a daemon thread.
This example is a MRE that hungs with the current lib version. This PR fixes this behaviour and correctly closes the application.