How can I add Timer to my GAE application?

94 views
Skip to first unread message

Alex Cheng

unread,
Nov 16, 2008, 10:48:31 PM11/16/08
to Google App Engine
I want to add a timer to my GAE application, so I can execute certain
logic at given interval. I tried python's Timer object (http://
www.python.org/doc/2.5.2/lib/timer-objects.html), but it doesn't seem
to work properly.

Alexander Kojevnikov

unread,
Nov 17, 2008, 12:14:45 AM11/17/08
to Google App Engine
> I want to add a timer to my GAE application, so I can execute certain
> logic at given interval. I tried python's Timer object (http://www.python.org/doc/2.5.2/lib/timer-objects.html), but it doesn't seem
> to work properly.

You cannot use the timer, create threads or spawn processes. See
comments in issue 6 for possible workarounds:
http://code.google.com/p/googleappengine/issues/detail?id=6

A.TNG

unread,
Nov 17, 2008, 10:09:54 AM11/17/08
to google-a...@googlegroups.com

If you want cron jobs, you may try this
http://code.google.com/p/gaeutilities/wiki/Cron.
Good luck. :-)

--
Best Regards,
TANG Jiyu (Blog: http://jiyu.wordpress.com.cn)

Maciej Pietrzak

unread,
Nov 17, 2008, 3:20:05 PM11/17/08
to Google App Engine
On 17 Lis, 16:09, A.TNG <tang.j...@gmail.com> wrote:
> On Mon, Nov 17, 2008 at 11:48 AM, Alex Cheng <AlexCheng1...@gmail.com> wrote:
>
> > I want to add a timer to my GAE application, so I can execute certain
> > logic at given interval. I tried python's Timer object (http://
> >www.python.org/doc/2.5.2/lib/timer-objects.html), but it doesn't seem
> > to work properly.
>
> If you want cron jobs, you may try this http://code.google.com/p/gaeutilities/wiki/Cron.
> Good luck. :-)

Or you can try my http://schedulerservice.appspot.com/

Main difference is that gaeutilities Cron runs inside your own app
inside requests initiated by regular (human) clients. Cron tasks will
not fire if there are no viewers, but generally every useful site has
at least some page views per day, so that shouldn't be a big problem.

On the other hand, Scheduler Service uses agents that call your url
from external hosts, so the whole thing doesn't depend on human
guests. But those external agents run on my servers, not Google's
ones, so if I were you I woudn't expect them to be that reliable
(altough me being me - I do expect them do be reliable, because I
simply trust myself ;). Also, with gaeutilities you can define any
number of tasks that will execute as often as you like as long as
there are human-initiated page views on your site. Scheduler Service
let's you define only a few schedulers that run at most 1 time per
hour.

Maybe the best thing would be to mix two technologies in new sites,
that is - run Cron tasks from both human and schedulerservice urls and
after your site (hopefully) gets some audience, drop schedulerservice
part?

Hope that helps.

Regards
Maciej

Alex Cheng

unread,
Nov 18, 2008, 2:01:21 AM11/18/08
to Google App Engine
I used Cron from gaeutilities and it works fine for me.

Finally I can remove a damn button from my page since the user doesn't
need to manually click it to refresh the page but Cron will do it in
the background.

That's really cool!

On Nov 18, 4:20 am, Maciej Pietrzak <mpietr...@gmail.com> wrote:
> On 17 Lis, 16:09, A.TNG <tang.j...@gmail.com> wrote:
>
> > On Mon, Nov 17, 2008 at 11:48 AM, Alex Cheng <AlexCheng1...@gmail.com> wrote:
>
> > > I want to add a timer to my GAE application, so I can execute certain
> > > logic at given interval. I tried python's Timer object (http://
> > >www.python.org/doc/2.5.2/lib/timer-objects.html), but it doesn't seem
> > > to work properly.
>
> > If you want cron jobs, you may try thishttp://code.google.com/p/gaeutilities/wiki/Cron.
> > Good luck. :-)
>
> Or you can try myhttp://schedulerservice.appspot.com/

bowman...@gmail.com

unread,
Nov 18, 2008, 9:55:03 AM11/18/08
to Google App Engine
Just be aware, Cron is extremely new and is still developmental. If
you have problems please report any issues at the gaeutilities project
site. http://code.google.com/p/gaeutilities/

I did my best to test all possible cron syntax to make sure it works
but rewriting that in python was a bit of a chore. Maciej is correct
on the functionality requiring pageviews to your site. It also will
currently only hit the site it's installed on for tasks. I've had a
weird issue where I couldn't submit a ":" to the webapp application
that supports the backend for it. That's why it requires relative,
rather than absolute, urls.
Reply all
Reply to author
Forward
0 new messages