From 1a6444f544eae56b10631b56db97b95bac594cd3 Mon Sep 17 00:00:00 2001 From: "MaYurD :)" Date: Sun, 9 Jun 2019 20:11:02 +0530 Subject: [PATCH] worker status fixed --- README.md | 4 +++- draught/pool.go | 16 +++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index da565e7..7ad59a4 100644 --- a/README.md +++ b/README.md @@ -200,7 +200,9 @@ To log pool status after every specified batch of jobs complition. ##### Time profiler ``` pool.SetTimeProfiler(500 * time.Millisecond) -To log pool status after every specified time. +To log pool status after every specified time. +If the pool worker got stuck at same process for more than +thrice of the profiler time then it will log the worker current status. ``` #### Profiler Example ``` diff --git a/draught/pool.go b/draught/pool.go index 8369a37..d68263b 100644 --- a/draught/pool.go +++ b/draught/pool.go @@ -162,13 +162,15 @@ func (p *Pool) workerStatus() { } for _, w := range p.workerPool { - msg = fmt.Sprintf("Value %v Error %v\n", - w.job.GetValue(), w.job.GetError()) - if p.consoleLog { - d = color.New(color.FgBlack) - d.Print(msg) - } else { - log.Print(msg) + if w.working { + msg = fmt.Sprintf("Value %v Error %v\n", + w.job.GetValue(), w.job.GetError()) + if p.consoleLog { + d = color.New(color.FgBlack) + d.Print(msg) + } else { + log.Print(msg) + } } } }