views:

60

answers:

2

I'm developing a site for a customer which regularly sends email notifications, to facilitate this I have a cron job which runs at 2am to start scheduling individual tasks to send out the notications. This is all fine and work perfectly with tasks being scheduled to execute immediately, but to assist development and testing I've written some CLI apps which use ipython and the remote_api_stub to interact with my application and datastore, when I schedule tasks on the command line like this:

task = taskqueue.Task(url='/admin/tasks/email', params={'email': email, 'type': notif.type})
task.add("email")

I get a 1 hour delay on the task execution. Why is this? and is there a way to get the task to execute immediately?

+2  A: 

If you want it to execute immediately, just open the URL in a browser. Why muck around with Task queues?

Adam Crossland
Thanks, but tasks are called with `POST` not `GET`, so not really a solution.
Peter Farmer
But a Task is just a URL that is handled by a RequestHandler in your application, and you can easily make it run the same code regardless of whether it is called with GET or POST.
Adam Crossland
+3  A: 

There seems to be a timezone-related bug in the SDK that causes the eta for tasks created through the remote API to be scheduled one hour after they're added. If you explicitly set the countdown to 0, the task should be scheduled to run immediately.

Wooble
Thanks but using `task = taskqueue.Task(url='/admin/tasks/email', params={'email': email, 'type': notif.type}, countdown=0)` still schedules in 1 hour `:/`
Peter Farmer
Try setting the ETA to the past, instead.
Nick Johnson