From 18588d48cbe186dcae112890d50c858cebf99711 Mon Sep 17 00:00:00 2001 From: qydysky Date: Sat, 3 Jun 2023 03:55:08 +0800 Subject: [PATCH] add --- reqf/Reqf.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/reqf/Reqf.go b/reqf/Reqf.go index f3c9818..707cea7 100644 --- a/reqf/Reqf.go +++ b/reqf/Reqf.go @@ -405,8 +405,16 @@ func (t *Req) withCtxTO(ctx context.Context, to time.Duration, w io.Writer, r io for { select { case <-ctx.Done(): - if chanw.Load() != 0 { - panic(fmt.Sprintf("write blocking after Ctx Done, goruntime leak \n%v", callTree)) + if old, now := chanw.Load(), time.Now(); old != 0 && now.Unix()-old > int64(to.Seconds()) { + if chanw.Load() != 0 { + panic(fmt.Sprintf("write blocking after %v, goruntime leak \n%v", now.Unix()-old, callTree)) + } + } else { + time.AfterFunc(to, func() { + if chanw.Load() != 0 { + panic(fmt.Sprintf("write blocking after %v, goruntime leak \n%v", now.Unix()-old, callTree)) + } + }) } return case now := <-timer.C: -- 2.39.2