# HG changeset patch # User russes02 # Date 1345140490 14400 # Thu Aug 16 14:08:10 2012 -0400 # Node ID edcb46a6811d251dccae076b8e4099d5f08af87d # Parent 8bd3af4fcd773795087ab9a649d2d10fd71cc5e1 Increase timeout incrementally on each failure diff --git a/fetchpage.go b/fetchpage.go --- a/fetchpage.go +++ b/fetchpage.go @@ -23,7 +23,7 @@ resultB := make(chan *Result, 2) phanTimeout := "300" if page.Attempts() > 1 { - phanTimeout = "5000" + phanTimeout = fmt.Sprintf("%d", (page.Attempts()+1) * 5000) } if page.OriginImage() == "" { go fetchPage(phan1, phanTimeout, page.OriginURL(), resultA) @@ -31,7 +31,7 @@ if page.CopyImage() == "" { go fetchPage(phan2, phanTimeout, page.CopyURL(), resultB) } - timer := time.AfterFunc(time.Duration(timeout)*time.Second, func() { + timer := time.AfterFunc(time.Duration(timeout * int64(page.Attempts()+1))*time.Second, func() { resultA <- nil resultB <- nil })