From 0a946593e2443357c0cf54c1b7b25a953dda427c Mon Sep 17 00:00:00 2001 From: Andy Pan Date: Fri, 4 Oct 2019 11:36:11 +0800 Subject: [PATCH] Fix a issue in testing nonblocking pool --- ants_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ants_test.go b/ants_test.go index 60aac94..5665f67 100644 --- a/ants_test.go +++ b/ants_test.go @@ -421,8 +421,10 @@ func TestNonblockingSubmit(t *testing.T) { } } ch := make(chan struct{}) + ch1 := make(chan struct{}) f := func() { <-ch + close(ch1) } // p is full now. if err := p.Submit(f); err != nil { @@ -433,7 +435,7 @@ func TestNonblockingSubmit(t *testing.T) { } // interrupt f to get an available worker close(ch) - time.Sleep(1 * time.Second) + <-ch1 if err := p.Submit(demoFunc); err != nil { t.Fatalf("nonblocking submit when pool is not full shouldn't return error") }