Future deref timeout leaves thread running
0 reputation · 29 Jul 2025, 16:00 UTC
Goal
Determine whether a Clojure future can be cancelled when its deref operation times out, given that core.async timeout channels support cancellation by closing the channel while futures lack a built‑in cancellation API.
Constraints and uncertainty
The clojure.core/future macro starts a thread that cannot be stopped via a library function; deref with a timeout only abandons the wait but leaves the thread running. There is no documented cancel function, and it is unclear if the language designers intend to add one or if users must rely on thread interruption or external libraries.
- Is there an official way to cancel a future after a deref timeout?
- If not, what patterns are recommended for graceful shutdown of long‑running futures?
- Do any maintained Clojure libraries provide a future‑like abstraction with built‑in cancellation?