Clojure http-kit get request stuck on multiple async calls -
i have created small example highlight problem:
(->> (range 0 4) (mapv (fn [i] (http/get "http://http-kit.org/" (fn [res] (info "first callback") (let [res2 @(http/get "http://http-kit.org/")] (info "second callback "))))))) it's stuck on printing 4s first callback msg's.
if change range 0..3 work, sync version works.
update:
the (info) taoensso.timbre logging library
my current hypothesis deadlock exhausting thread-pool:
- you create thread per outer http/get
- if create less requests available threads in thread pool, there room service @ least 1 inner
http/get(which require new thread)- or if first request completed before exhaust thread-pool
- once there no more threads in thread-pool, inner
http/getcannot serviced - since inner request cannot completed, outers stuck forever
you can check status of thread-pool http-kit uses peeking http/default-pool. there can see things like:
#object[java.util.concurrent.threadpoolexecutor 0x5a99e5c "java.util.concurrent.threadpoolexecutor@5a99e5c[running, pool size = 8, active threads = 0, queued tasks = 0, completed tasks = 24]"] when did not deadlock. or
#object[java.util.concurrent.threadpoolexecutor 0x5a99e5c "java.util.concurrent.threadpoolexecutor@5a99e5c[running, pool size = 8, active threads = 8, queued tasks = 8, completed tasks = 28]"] when did.
i have tested in machine (shows 8 (.availableprocessors (runtime/getruntime))) , got results above. walked deadlock when run more 8 requests.
regards

Comments
Post a Comment