Fork me on GitHub
#core-async
<
2018-06-08
>
Andy02:06:36

qq: what is an idiomatic way to wait for go block to complete. I have a fully async piece in -main. I currently use (.join (Thread/currentThread)) but that does not work when go block actually cease to exists.

noisesmith02:06:32

the go block returns a channel which returns a value when the block exits

noisesmith02:06:04

if you call <!! on the return value of go, it will wait until the block exits

Andy03:06:37

I tested it and it works just fine for a simple case. <!! is a last statement in my -main. Now, with starting more channels which depend on itself, I am running into an opposite question. main go block nicely exists nad <!! captures that, but for some reason the program does not want to exist. What possibly could block it to do so? (I realize that it is far fetched questions without many details, but I am looking for clues)

noisesmith03:06:54

(shutdown-agents) is needed if you have used things like core.async that use clojure's internal thread pools

noisesmith03:06:19

assuming you meant "does not exit" rather than "does not exist"

Andy03:06:37

yes, that was a typo.

Andy04:06:31

so (shutdown-agents) does not do the trick. Is there any way to find out which thread is blocking?

noisesmith04:06:59

are you still trying to join the current thread? that should just block forever

noisesmith04:06:02

you can use Control-\ in the console, or the jstack [pid] command to find out what all the threads are doing

Andy20:06:32

@ noisesmith -> thx a lot for the support. I used jstack and lead me to a very specific cause and now I fixed the root of the issue ...