Fork me on GitHub

i'm trying to gracefully stop some code that's using mult/tap. i'm shutting down the producer that writes to the mult and waiting until all of the mult and tap buffers are empty. but that won't be enough if one of the tap consumers takes a bit of time to process the last item coming out of the tap. i started looking at keeping track of whether the consumers are processing an item or waiting for a new one. but i can't figure out a way keep track of that kind of state without a race condition. has anyone attempted something like this? i'm wondering if i should be using a part of core async other than mult/tap


@jjfine why not wait for the code containing the consumers of the taps to exit? eg. wait on the channel that go returned


oh wow that's too obvious


np - it takes a while for the natural / easy choice to be intuitive with core.async haha


but yeah, a good rule of thumb is that it’s easier to wait on a channel rather than a consumer, and you can always ensure that consumer closes a channel (in fact it is probably doing so already whether you think of it that way or not)


I invariably end up passing a second "exit" channel to anything I launch, and use alts to consume from either whatever channel to get data and do whatever(and then loop), or consume from the exit channel and exit