Fix(picker): add WithTimeout for some situation

This commit is contained in:
Dreamacro
2019-07-18 00:12:01 +08:00
parent 0670275533
commit f00dfdd34d
5 changed files with 22 additions and 9 deletions

View File

@ -111,9 +111,8 @@ func getProxyDelay(w http.ResponseWriter, r *http.Request) {
proxy := r.Context().Value(CtxKeyProxy).(C.Proxy)
ctx, cancel := context.WithTimeout(context.Background(), time.Millisecond*time.Duration(timeout))
picker, ctx, cancel := picker.WithTimeout(context.Background(), time.Millisecond*time.Duration(timeout))
defer cancel()
picker, ctx := picker.WithContext(ctx)
picker.Go(func() (interface{}, error) {
return proxy.URLTest(ctx, url)
})