fixed grabbing jobs
This commit is contained in:
parent
cdfe4fff6c
commit
e18e782bba
@ -7,6 +7,7 @@ package worker
|
|||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
|
"time"
|
||||||
"bitbucket.org/mikespook/gearman-go/common"
|
"bitbucket.org/mikespook/gearman-go/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -57,12 +58,17 @@ func (a *agent) inLoop() {
|
|||||||
a.worker.removeAgent(a)
|
a.worker.removeAgent(a)
|
||||||
}()
|
}()
|
||||||
noop := true
|
noop := true
|
||||||
|
go func() {
|
||||||
for a.worker.running {
|
for a.worker.running {
|
||||||
RESTART:
|
|
||||||
// got noop msg and in queue is zero, grab job
|
|
||||||
if noop && len(a.in) == 0 {
|
if noop && len(a.in) == 0 {
|
||||||
a.WriteJob(newJob(common.REQ, common.GRAB_JOB, nil))
|
a.WriteJob(newJob(common.REQ, common.GRAB_JOB, nil))
|
||||||
}
|
}
|
||||||
|
<-time.After(time.Second)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
for a.worker.running {
|
||||||
|
RESTART:
|
||||||
|
// got noop msg and in queue is zero, grab job
|
||||||
rel, err := a.read()
|
rel, err := a.read()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == common.ErrConnection {
|
if err == common.ErrConnection {
|
||||||
|
Loading…
Reference in New Issue
Block a user