using time.After instead of a separate goroutine
This commit is contained in:
parent
5f581dd0e6
commit
624c61519f
@ -235,17 +235,10 @@ func (client *Client) Do(funcname string, data []byte, flag byte) (handle string
|
|||||||
rel = append(rel, data...) // len(data)
|
rel = append(rel, data...) // len(data)
|
||||||
client.writeJob(newJob(common.REQ, datatype, rel))
|
client.writeJob(newJob(common.REQ, datatype, rel))
|
||||||
// Waiting for JOB_CREATED
|
// Waiting for JOB_CREATED
|
||||||
timeout := make(chan bool)
|
|
||||||
defer close(timeout)
|
|
||||||
go func() {
|
|
||||||
defer common.DisablePanic()
|
|
||||||
time.Sleep(client.TimeOut)
|
|
||||||
timeout <- true
|
|
||||||
}()
|
|
||||||
select {
|
select {
|
||||||
case job := <-client.jobCreated:
|
case job := <-client.jobCreated:
|
||||||
return string(job.Data), nil
|
return string(job.Data), nil
|
||||||
case <-timeout:
|
case <-time.After(client.TimeOut):
|
||||||
return "", common.ErrJobTimeOut
|
return "", common.ErrJobTimeOut
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user