core-async

p-himik 2021-05-24T15:49:16.001200Z

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

alexmiller 2021-05-24T15:55:11.001600Z

maybe you should not do that :)

p-himik 2021-05-24T15:59:42.001900Z

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.

alexmiller 2021-05-24T16:02:22.002100Z

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

p-himik 2021-05-24T16:04:20.002300Z

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.

alexmiller 2021-05-24T16:09:01.002500Z

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

alexmiller 2021-05-24T16:09:48.002700Z

the pipeline fns retain order

p-himik 2021-05-24T16:13:47.002900Z

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

alexmiller 2021-05-24T16:23:07.003200Z

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

p-himik 2021-05-24T16:25:51.003400Z

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!

alexmiller 2021-05-24T16:27:41.003600Z

sorry, maybe I'm misremembering the details