You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is no need to panic when cancelling a cancelled request. And no document says that is not allowed.
It is hard to ensure a request is canceled without CancelRequest retry:
go func() { c <- f(client.Do(req)) }()
select {
case <-ctx.Done():
tr.CancelRequest(req)
<-c // Wait for f to return.
return ctx.Err()
case err := <-c:
return err
}
(code from https://blog.golang.org/context)
It is possible that the request is canceled before Do is called, and it needs CancelRequest retry to ensure it is canceled.
If i call CancelRequest twice on the same request, CancelRequest will panic because of close a closed channel at here:
https://golang.org/src/net/http/transport.go#L517
I argue that CancelRequest should not panic here:
(code from https://blog.golang.org/context)
It is possible that the request is canceled before Do is called, and it needs CancelRequest retry to ensure it is canceled.
from https://github.com/coreos/go-etcd/issues/197
The text was updated successfully, but these errors were encountered: