Just found that (a/<!! (a/map vector []))
hangs.
Is it the desired behavior?
maybe you should not do that :)
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.if you want to add an ask.clojure question for it I can add a check for that
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.
not sure a/map is the best tool for that, seems more like a pipeline-async kind of thing
the pipeline fns retain order
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
yeah, I think you want to give it the channel passed to the async function
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!
sorry, maybe I'm misremembering the details