I want call to two GET requests from my App in App Engine. I want to sleep for few minutes after calling the first request and then call the second request. If I add time.sleep() in the code I am able to deploy code but if I hit the URL of the App it gives me ->
Error: Server Error
The server encountered an error and could not complete your request.
Please try again in 30 seconds.
health-policy.go
isHealthy, err = h.CampaignService.Run(ctx)
return err
if isHealthy {
startTime = time.Now().Format(time.RFC3339)
//The line below causes 500 error
time.Sleep(3 * time.Minute)
isHealthy, err = h.ReportService.GenerateReport(ctx, startTime)
}
campaign-run-service.go
req, err = http.NewRequest("GET", "URL1", nil)
client := urlfetch.Client(ctx)
res, err = client.Do(req)
if err == nil && res.StatusCode == http.StatusOK {
return true, err
}
fmt.Println("Error in Run Service ->", err)
return false, err
generate-report-service.go
req, err = http.NewRequest("GET", "URL2", nil)
client := urlfetch.Client(ctx)
res, err = client.Do(req)
if err == nil && res.StatusCode == http.StatusOK && res.ContentLength > 400 {
return true, err
}
return false, err
I am new to App Engine, also using sleep in app engine code a good idea if not than what is the alternative?