File tree Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -205,9 +205,9 @@ func (s *Worker) Shutdown() error {
205
205
}
206
206
207
207
s .stopOnce .Do (func () {
208
- close (s .stop )
209
208
s .pubsub .Close ()
210
209
s .rdb .Close ()
210
+ close (s .stop )
211
211
})
212
212
return nil
213
213
}
@@ -244,7 +244,7 @@ func (s *Worker) Run() error {
244
244
// check queue status
245
245
select {
246
246
case <- s .stop :
247
- return queue . ErrQueueShutdown
247
+ return nil
248
248
default :
249
249
}
250
250
@@ -263,6 +263,13 @@ func (s *Worker) Run() error {
263
263
}
264
264
265
265
for {
266
+ // check queue status
267
+ select {
268
+ case <- s .stop :
269
+ return nil
270
+ default :
271
+ }
272
+
266
273
select {
267
274
case m , ok := <- ch :
268
275
select {
Original file line number Diff line number Diff line change @@ -251,10 +251,10 @@ func TestGoroutineLeak(t *testing.T) {
251
251
m .Message = fmt .Sprintf ("foobar: %d" , i + 1 )
252
252
assert .NoError (t , q .Queue (m ))
253
253
}
254
- time .Sleep (2 * time .Second )
254
+ time .Sleep (1 * time .Second )
255
255
q .Shutdown ()
256
256
q .Wait ()
257
- time .Sleep (2 * time .Second )
257
+ time .Sleep (1 * time .Second )
258
258
fmt .Println ("number of goroutines:" , runtime .NumGoroutine ())
259
259
}
260
260
You can’t perform that action at this time.
0 commit comments