Fork me on GitHub
#core-async
<
2021-05-24
>
p-himik15:05:16

Just found that (a/<!! (a/map vector [])) hangs. Is it the desired behavior?

Alex Miller (Clojure team)15:05:11

maybe you should not do that :)

p-himik15:05:42

Well, I'm not using [] of course. :) It's just a collection produced by

(map
  (fn [item]
    (cognitect.aws.client.api.async/invoke ...))
  items)
So when items is empty, it hangs. I can check for it, but wondered that maybe it's worth mentioning in the docstring or checking for it in a/map given how easy it is to hang the thread with it.

Alex Miller (Clojure team)16:05:22

if you want to add an ask.clojure question for it I can add a check for that

p-himik16:05:20

Will do! BTW do you have any opinion on the above code and using (a/<!! (a/map vector ...)) to gather the results in order? Pretty much my first foray into clojure.core.async, so rather cautious about every step.

Alex Miller (Clojure team)16:05:01

not sure a/map is the best tool for that, seems more like a pipeline-async kind of thing

Alex Miller (Clojure team)16:05:48

the pipeline fns retain order

p-himik16:05:47

Oh, so with pipeline-async I will be using the :ch optional argument to aws-async/invoke, right? Posted that question: https://ask.clojure.org/index.php/10652/easy-to-hang-the-current-thread-with-map-chs-when-chs-is-empty

Alex Miller (Clojure team)16:05:07

yeah, I think you want to give it the channel passed to the async function

p-himik16:05:51

But that won't work, unless I call aws-async/invoke in the function passed as the third argument to pipeline-async (assuming that even make sense). After all, multiple calls to aws-async/invoke with the same channel can result in the results arriving in a different order. So pipeline-async will preserve the order, but that order will be wrong. In any case, I will definitely experiment with pipeline-async, thanks!

Alex Miller (Clojure team)16:05:41

sorry, maybe I'm misremembering the details