splunk / pipelines

Concurrent processing pipelines in Go.
MIT License
21 stars 8 forks source link

fix reduce test #16

Closed Lng88 closed 2 years ago

Lng88 commented 2 years ago

Not sure if this is the right way to fix this test, but I have a question about cancel(). It seems like cancel() is performing some async operation and does not satisfy the ctx.Done() case until after a receiving some values from the in channel of the Reduce function. Is this true?

I don't see anything documented in the official go docs, but I found this which I think mentions the behavior? https://github.com/golang/go/issues/33185

kalexmills-splunk commented 2 years ago

Yes, you got the fix right. Sorry I missed your PR.

The issue with the test is that we don't have any control over whether the pipeline has sent some prefix of the input before it detects context cancellation. Making a really long input increases the chance the pipeline won't complete before detecting the cancelled context, but it's not fool-proof.