Reputation: 1647
I can see my task running but I dont see anything on my page with self.response.out.write()
I do it like this:
class CounterWorker(webapp.RequestHandler):
def post(self): # should run at most 1/s
self.response.out.write("<a href='/'>start over</a><br /><br />")
class MainHandler(webapp.RequestHandler):
def post(self, mode=""):
taskqueue.add(url='/worker', countdown=10)
Upvotes: 1
Views: 52
Reputation: 599490
No. I don't understand why you would expect any output.
A task is a separate process. The whole point of a task is that it runs completely separately from the code that interacts with the user. It's for performing long-running calculations that do not need user output.
So, your user-facing code - which needs to complete within 30 seconds - accepts any parameters from the user, triggers the task, and then responds immediately to the user (to say, for example, 'processing triggered'). Your task then goes off and does its work. There is no way for that task to communicate directly back to the user, because the original request has finished.
If you wanted, you could get your task to set a flag somewhere (in a datastore entity or memcache) that determines the current status of the processing, and then you could write some Ajax to call a handler that accesses that flag and tells the user if it is finished. But you simply cannot write directly to output in a task.
Upvotes: 3