Fork me on GitHub
#core-async
<
2017-10-24
>
nkabrich09:10:39

the docstring for pipeline-async states: "By default, the to channel will be closed when the from channel closes, but can be determined by the close? parameter." Do we have to worry about race conditions here and handle that manually? Like if the from channel closes causing the to channel to close before all the async transformations are finished? Or is that not a concern here?

noisesmith16:10:08

this should be easy to test with some timeout reads, but I’d assume that what it would actually do is wait until from gives it a nil (meaning channel is closed and buffer drained) and then only close the to when all puts resulting via processing from have completed (and once again, the consumer of to wouldn’t see the close until the buffer is drained)

noisesmith16:10:24

this is the implementation function pipeline-async invokes https://github.com/clojure/core.async/blob/master/src/main/clojure/clojure/core/async.clj#L478 but I can’t tell for sure from reading the code if the issue you describe holds

nkabrich08:10:41

thanks ya I did a few tests and there didn't seem to be any race conditions, but that doesn't mean it can't happen. I too tried quickly reading through that code and wasn't 100% sure if it could still happen. I guess I'll have to take the time to read it more thoroughly

noisesmith17:10:38

there are ways to make race conditions more likely - randomized delay times, running thousands of iterations and verifying if any of them raced

abdullahibra09:10:17

this code create N channels and pass list to each channel linearly to remove multipliers

abdullahibra09:10:51

the code works fine for example till 10000 odds [11:02] when i tried to increase more for example 100000 it's broken [11:02] anybody can help in this?

hiredman16:10:20

the exception you only pasted the middle of is a stackoverflow exception

hiredman16:10:19

because you are building up a bunch of filters, and every layer of filter (every layer of lazy seq) adds another stack frame when you go to realize it