Reputation: 6958
I cannot get the appengine taskqueue to accept any context I throw at it:
import (
"context"
"google.golang.org/appengine"
"google.golang.org/appengine/taskqueue"
)
/* snip */
ctx:= context.Background()
task := taskqueue.NewPOSTTask("/b/mytask", params)
_, err = taskqueue.Add(ctx, task, "")
if err != nil {
return fmt.Errorf("adding background task with path %s: %v", task.Path, err)
}
I'm calling appengine.Main() in my main.go main func as stated by the go111 migration docs (But this line is missing in go112 migration docs so I'm not sure it's required).
I've tried:
context.Background()
request.Context()
appengine.NewContext(r)
appengine.BackgroundContext()
context.TODO()
All result in error:
not an App Engine context
except for appengine.BackgroundContext()
which gets:
service bridge HTTP failed: Post http://appengine.googleapis.internal:10001/rpc_http: dial tcp 169.254.169.253:10001: i/o timeout
Upvotes: 3
Views: 1003
Reputation: 755
You're seeing internal.flushLog: Flush RPC: service bridge HTTP failed
because you have appengine.Main()
or other appengine
lib calls while trying to run a Go 1.12+ runtime. (My guess is that the older runtime had to call into some Google-internal accounting infrastructure and that's not available for the 1.12 "next gen" systems.)
The solution isn't to downgrade your Go versions -- you're missing a ton of performance and security improvements doing that, and you can't take advantage of the new hardware -- the solution is to remove all the calls to the appengine
lib and use GCP's cloud libraries instead (see https://godoc.org/cloud.google.com/go)
Upvotes: 0
Reputation: 20146
The documentation for migration to 1.12 states:
Use Cloud Tasks to enqueue tasks from Go 1.12 using the cloudtasks package. You can use any App Engine service as the target of an App Engine task.
But the cloudtasks package documentation (as at today’s date) is clearly marked as beta and unstable. So the answer here is probably. This feature is unsupported.
That said, I’m using it in production under go111 without any serious issue that I have noticed so far.
Upvotes: 2
Reputation: 91
I experienced the same problems when migrating a GAE standard project from go19 to go112 in order to use go modules. In addition I got a lot of "502 bad gateway" messages.
Replacing http.ListenAndServe() in main() with appengine.Main() fixed the context problem. Moving to go111 instead of 112 took care of the other issue. The docs and examples are not very clear on this.
Upvotes: 6