fix context cancelling
This commit is contained in:
parent
db07a432cd
commit
5a2584188f
|
|
@ -185,7 +185,6 @@ func main() {
|
||||||
failCount := 0
|
failCount := 0
|
||||||
for {
|
for {
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*time.Duration(*flSyncTimeout))
|
ctx, cancel := context.WithTimeout(context.Background(), time.Second*time.Duration(*flSyncTimeout))
|
||||||
defer cancel()
|
|
||||||
err := syncRepo(ctx, *flRepo, *flBranch, *flRev, *flDepth, *flRoot, *flDest)
|
err := syncRepo(ctx, *flRepo, *flBranch, *flRev, *flDepth, *flRoot, *flDest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if initialSync || failCount >= *flMaxSyncFailures {
|
if initialSync || failCount >= *flMaxSyncFailures {
|
||||||
|
|
@ -196,6 +195,7 @@ func main() {
|
||||||
failCount++
|
failCount++
|
||||||
log.Errorf("unexpected error syncing repo: %v", err)
|
log.Errorf("unexpected error syncing repo: %v", err)
|
||||||
log.V(0).Infof("waiting %v before retrying", waitTime(*flWait))
|
log.V(0).Infof("waiting %v before retrying", waitTime(*flWait))
|
||||||
|
cancel()
|
||||||
time.Sleep(waitTime(*flWait))
|
time.Sleep(waitTime(*flWait))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
@ -215,6 +215,7 @@ func main() {
|
||||||
|
|
||||||
failCount = 0
|
failCount = 0
|
||||||
log.V(1).Infof("next sync in %v", waitTime(*flWait))
|
log.V(1).Infof("next sync in %v", waitTime(*flWait))
|
||||||
|
cancel()
|
||||||
time.Sleep(waitTime(*flWait))
|
time.Sleep(waitTime(*flWait))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue