On Thu, Nov 3, 2016 at 1:27 AM, Axel Wagner <axel.wagner...@googlemail.com> wrote:
> That is actually a great point I haven't thought about and the crux of the > matter (sorry for repeating it, but I think it's worth making very > explicit): > > While cancelFunc can only be called from the goroutine that created the > context, Err can be called downstack. Meaning, if I call cancelFunc, a call > *might or might not* return Cancelled as an error. It might not actually > implement cancellation or the call might have failed or succeeded > concurrently with a different (non-)error. > > The ctx.Err() return thus allows a "child-function" to signal back whether > a cancellation was *successful*; the creator of the context only know that > it has been *tried*. > No, that's really not its intent. Cancel means *STOP IT!*, and any goroutines down the chain are supposed to block until they're really done, returning ASAP. It's a nasty bug to disrespect that, because the call site will assume that the background noise stopped once the function returned, and act accordingly thereafter. gustavo @ http://niemeyer.net -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.