From db57227ae53d3e8bba8a5cf939fb2b165d9ceaaf Mon Sep 17 00:00:00 2001 From: Alexander Scharinger Date: Sat, 27 Mar 2021 22:54:06 +0100 Subject: Github bridge: stop sleep-timer on SIGINT --- bridge/github/import_mediator.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/bridge/github/import_mediator.go b/bridge/github/import_mediator.go index 25d9c312..ac094bbb 100644 --- a/bridge/github/import_mediator.go +++ b/bridge/github/import_mediator.go @@ -358,8 +358,14 @@ func (mm *importMediator) mQuery(ctx context.Context, query rateLimiter, vars ma var err error for i := 0; i < retries; i++ { // wait a few seconds before retry - sleepTime := 8 * (i + 1) - time.Sleep(time.Duration(sleepTime) * time.Second) + sleepTime := time.Duration(8*(i+1)) * time.Second + timer := time.NewTimer(sleepTime) + select { + case <-ctx.Done(): + stop(timer) + return ctx.Err() + case <-timer.C: + } err = mm.queryOnce(ctx, query, vars) if err == nil { // success: done -- cgit