-
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
Ordered shutdown hooks for dependent threadpools #46
Comments
Hi there! Sorry for the delay. I like the idea of managed shutdown. In general, however, the dependency graph might be cyclic, e.g.: (def http-pool (cp/threadpool))
(def db-pool (cp/threadpool))
(def results
(->> items
(cp/pmap http-pool http-request-1)
(cp/pmap db-pool fetch-db-data)
(cp/pmap http-pool http-request-2))) Also, I do think something like https://github.com/stuartsierra/component is generally a better fit than exit-hook magic. The main advantage of Component is avoiding global mutable state, and I think that would be helpful here. That said, if you have an API proposal, I'd be happy to consider it. The following considerations seem relevant:
Another option that might make sense is just to take your graceful shutdown article https://medium.com/helpshift-engineering/achieving-graceful-restarts-of-clojure-services-b3a3b9c1d60d and make it a library that composes nicely with Claypoole. (It didn't look like it was a published library yet, but I wasn't sure.) The advantage there is that you can make something more general-purpose, and it might help meet that need for more cases than just Claypoole threadpools. Thanks for the idea, and let me know how you want to follow up. |
Hey thanks for taking the time to reply in detail! Let me chalk up something, I like the idea of an independent project which can play well with shutting down threadpools in general. Initially, I was also thinking of a DAG-like approach (like namespaces which can't depend on each other), so in that respect, the |
Hi @mourjo , Do you think this issue is still relevant / something worth pursuing ? Leon does not work with Clojure and we managed to move the project here (clj-commons) and I stepped in to maintain it. I haven't had a chance to read through your proposal yet. Thanks, |
Hi! I wanted to ask, do you think it would be a good idea to have a lifecycle manager (a shutdown hook) for multiple claypoole threadpools for when the JVM gets a kill signal? Something like if threadpool
t1
uses another threadpoolt2
, then at the JVM shutdown, we would want the threadpoolt2
to shutdown first in order fort1
to be gracefully shut down without having tasks rejected? We could have one shutdown hook for all claypoole threads in a JVM and based on the dependency (which I guess needs to be mentioned at the time of creation of the pool), it could coordinate shutting down of the different pools. Do you think this would be something worth having in this project? I could start a pull request then. Wanted to get your opinion first.https://clojureverse.org/t/is-there-a-canonical-way-or-framework-to-handle-threads-lifecycle/6136
The text was updated successfully, but these errors were encountered: