func leaseConfs(ctx appengine.Context) (ts []*taskqueue.Task, err error) { for i, t := 0, 1; i < 3; i, t = i+1, 2*t { ts, err = taskqueue.Lease(ctx, 4, "review-conference-queue", 10) if err == nil { return } ctx.Errorf("lease tasks: %v", err) time.Sleep(time.Duration(t) * time.Second) } return }
func lease(w http.ResponseWriter, r *http.Request) { c := appengine.NewContext(r) tasks, err := taskqueue.Lease(c, 100, "pulltest", 3600) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } payloads := make([]string, 0, len(tasks)) for _, task := range tasks { payloads = append(payloads, string(task.Payload)) } je := json.NewEncoder(w) if err := je.Encode(payloads); err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } }