This commit is contained in:
cdle
2021-10-11 17:01:03 +08:00
parent ecec622323
commit 6b2419d2e4
3 changed files with 6 additions and 3 deletions
+3 -2
View File
@@ -247,18 +247,19 @@ func (sender *BaseSender) Await(callback func(string, error) interface{}, params
if oc, ok := waits.LoadOrStore(key, c); ok {
oc.(Carry).Chan <- InterruptError
}
defer waits.Delete(key)
select {
case result := <-c.Chan:
switch result.(type) {
case string:
waits.Delete(key)
c.Result <- callback(result.(string), nil)
return
case error:
waits.Delete(key)
c.Result <- callback("", result.(error))
}
return
case <-time.After(timeout):
waits.Delete(key)
c.Result <- callback("", TimeOutError)
}
}