Ver código fonte

Merge pull request #34 from tuna/dev

fix(worker): fix resource leakage caused by time.Tick(), closing #33
bigeagle 9 anos atrás
pai
commit
8cb46476cf
1 arquivos alterados com 2 adições e 1 exclusões
  1. 2 1
      worker/worker.go

+ 2 - 1
worker/worker.go

@@ -291,6 +291,7 @@ func (w *Worker) runSchedule() {
 
 	w.L.Unlock()
 
+	tick := time.Tick(5 * time.Second)
 	for {
 		select {
 		case jobMsg := <-w.managerChan:
@@ -326,7 +327,7 @@ func (w *Worker) runSchedule() {
 				w.schedule.AddJob(schedTime, job)
 			}
 
-		case <-time.Tick(5 * time.Second):
+		case <-tick:
 			// check schedule every 5 seconds
 			if job := w.schedule.Pop(); job != nil {
 				job.ctrlChan <- jobStart