create new context on context cancelled

This commit is contained in:
Antoni Sawicki 2019-06-08 17:32:35 -07:00
parent d9381ef71a
commit 92f3cb7aee
1 changed files with 10 additions and 3 deletions

13
wrp.go
View File

@ -181,9 +181,16 @@ func capture(gourl string, w int64, h int64, s float64, co int, p int64, i bool,
chromedp.Nodes("a", &nodes, chromedp.ByQueryAll))
if err != nil {
log.Printf("%s %s", c, err)
fmt.Fprintf(out, "<BR>%s<BR>", err)
return
if err.Error() == "context canceled" {
log.Printf("%s Contex cancelled, try again", c)
fmt.Fprintf(out, "<BR>%s<BR> -- restarting, try again", err)
ctx, cancel = chromedp.NewContext(context.Background())
return
} else {
log.Printf("%s %s", c, err)
fmt.Fprintf(out, "<BR>%s<BR>", err)
return
}
}
log.Printf("%s Landed on: %s, Nodes: %d\n", c, loc, len(nodes))