From fafecdfd17395af434e6053396b08afa71568706 Mon Sep 17 00:00:00 2001 From: yaohcn Date: Thu, 23 Jul 2020 20:34:27 +0800 Subject: [PATCH] add RPC timeout --- sched.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sched.go b/sched.go index ed48d097b..af28b1902 100644 --- a/sched.go +++ b/sched.go @@ -258,7 +258,9 @@ func (sh *scheduler) trySched() { continue } - ok, err := task.sel.Ok(task.ctx, task.taskType, sh.spt, worker) + rpcCtx, cancel := context.WithTimeout(task.ctx, SelectorTimeout) + ok, err := task.sel.Ok(rpcCtx, task.taskType, sh.spt, worker) + cancel() if err != nil { log.Errorf("trySched(1) req.sel.Ok error: %+v", err) continue