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.

enter image description here

if change range 0..3 work, sync version works.

update:

the (info) taoensso.timbre logging library

my current hypothesis deadlock exhausting thread-pool:

  1. you create thread per outer http/get
  2. if create less requests available threads in thread pool, there room service @ least 1 inner http/get (which require new thread)
    1. or if first request completed before exhaust thread-pool
  3. once there no more threads in thread-pool, inner http/get cannot serviced
  4. 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

Popular posts from this blog

javascript - Create a stacked percentage column -

Optimising Firebase database by automatically overwriting data -

javascript - Angular UI-Grid customTemplate directive causing rows to load slowly/? -