views:

284

answers:

3

In its current format, Google App Engine's Cron allows that "The shortest time between runs of a task that can be specified is 1 minute." I have an application that where I would prefer it run a task every 10 seconds. Are there any workarounds?

+1  A: 

Perhaps after 9 seconds of processing you can invoke yet another cron URL from cron itself?

Not sure how that collides with their terms of usage though.

Robert Munteanu
+1  A: 

Depending how many hits your application gets (and how consistent they are), you could use the "poor mans cron" method..

On each page load, you check if the last execution time was >= 10 seconds ago - if so, trigger a function (either by calling the function in-line, or perhaps triggering the real cron URL?)

Aside from that - currently - no. Not until the background tasks are implemented, or the cron limitations are changed.


Edit: The Task Queue (background processing) feature has been implemented!

dbr
One caveat to the above approach: The user won't get the generated page until your code finishes executing, so executing a cron job in the background may result in a noticeable slowdown for users.
Nick Johnson
This may be stupid, but could I create another GAE app that just waits 10 seconds and then triggers the task on the original function. Am I forgetting something here?
ehfeng
How would you call that second app? I don't get it. Waiting for the upcoming task queue API really is a better approach. :)
Nick Johnson
It arrived!!! Now...to figure out how to use it. :P
ehfeng
+2  A: 

If you're patient, the Task Queue API will be out very shortly, which will provide for executing tasks with arbitrary delays.

Nick Johnson