Fork me on GitHub
#core-async
<
2018-08-24
>
reefersleep09:08:06

I’m using a pipeline-blocking and keeping the to channel around for later reference. At a certain point (when I detect an error), I want to close! the to channel, which, according to the documentation (as far as I can read) should stop consumption from the from channel. However, my xf, which processes the from output and puts it on the to, does some printing as a side effect, and I can see that it is printing for all of the entries from from even after I call (close! to). Am I misunderstanding something?

bjr14:08:09

looks like nobody’s responded — I’ve held off because I don’t know the answer and have not had time to dig in myself. however, I can say when it comes to these sorts of details with core.async I’ve just studied the source. Generally it’s not a bug but a subtle characteristic of the tool.

bjr14:08:00

my bet is there’s an internal channel between from and to which has the transducer

bjr14:08:28

and pipelines are designed to use feedback from the from channel’s open/closed status to update its internal state, not the to channel’s status

bjr14:08:14

so in summary — I don’t think the docs guarantee that closing the to channel immediately halts execution & processing of messages from the from channel

bjr14:08:00

if that’s what you need you may want to design something for your specific use case

bjr14:08:32

either instead of pipeline or by composing pipeline with other communicating proccesses

bjr14:08:14

a promise chan for flagging an error state consumed by an explicit non-blocking take (prioritized alts or poll) immediately before the side-effecting code comes to mind first

reefersleep09:08:36

(To be clear; I am not calling pipeline-blocking with a close? argument, rather, I am calling (close! to) manually.)