Periodic task in a Zope 2 environment
Hi all. A little of background, before. I need to run some tasks, inside a zope environment, in a periodic way. Even though I could resort to using cron and wget, I do not like the solution too much, also because it requires me to rely on something completly external to the application to schedule the task itsel (I need to update the cron to change how often a job is run... ). Now, I can see I can run a task using zopectl run + a script. My script would therefore be something like: while True: do something sleep(for sometime) of course, there are dozen of ways to write this in a better way, but that is not the problem. My problem is understanding if it is possible to run such a script via the zdaemon. Can anyone shred some light on this topic? Is there a better way to run such tasks in Zope 2 environments? Regards Marco -- Marco Bizzarri http://notenotturne.blogspot.com/ http://iliveinpisa.blogspot.com/
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 16.02.2009 16:59 Uhr, Marco Bizzarri wrote:
Is there a better way to run such tasks in Zope 2 environments?
ClockServer (build-in of Zope). Check your zope.conf. - -aj -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkmZjcAACgkQCJIWIbr9KYy9VQCdHTmLFhywU9kMXKi1Np7cx3mC egMAnRpP45PPI79bdXVdRg56gwRrmL2q =k+T3 -----END PGP SIGNATURE-----
On Mon, Feb 16, 2009 at 5:01 PM, Andreas Jung <lists@zopyx.com> wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
ClockServer (build-in of Zope). Check your zope.conf.
- -aj
Thanks for answering, Andreas. Is it reasonably safe to use Clock Server in Zope 2.8? (( Reasonably safe = there are no obvious or very well known problems in such a setup )) Regards Marco -- Marco Bizzarri http://notenotturne.blogspot.com/ http://iliveinpisa.blogspot.com/
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 16.02.2009 17:11 Uhr, Marco Bizzarri wrote:
On Mon, Feb 16, 2009 at 5:01 PM, Andreas Jung <lists@zopyx.com> wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
ClockServer (build-in of Zope). Check your zope.conf.
- -aj
Thanks for answering, Andreas.
Is it reasonably safe to use Clock Server in Zope 2.8?
*shrug* try it out - Zope 2.8 is basically obsolete. - -aj -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkmZkeIACgkQCJIWIbr9KYwLGgCg2Vlxbtm/R/2hVHRSR0cApah5 sRUAn2XP/qAnh+4agQqWxGEFlJkyK65D =DCfK -----END PGP SIGNATURE-----
Le lundi 16 février 2009 à 16:59 +0100, Marco Bizzarri a écrit :
Hi all.
A little of background, before.
I need to run some tasks, inside a zope environment, in a periodic way. Even though I could resort to using cron and wget, I do not like the solution too much, also because it requires me to rely on something completly external to the application to schedule the task itsel (I need to update the cron to change how often a job is run... ).
Now, I can see I can run a task using zopectl run + a script. My script would therefore be something like:
while True: do something sleep(for sometime)
of course, there are dozen of ways to write this in a better way, but that is not the problem. My problem is understanding if it is possible to run such a script via the zdaemon. Can anyone shred some light on this topic?
Hi, I don't know if it's the best way, but I've implemented a "cron like" task base class for my Zope-2.9 instance, which : - is thread based - can launch operations in a "cron like" way - can act as the user of your choice. It doesn't actually provide any user interface to define task scheduling, but the main base class could probably be used as a good starting point ; at least, it works ;-). I can send you the source code on request... Thierry Florac -- Chef de projet intranet/internet Office National des Forêts - Département Informatique 2, Avenue de Saint-Mandé 75570 PARIS Cedex 12 Mél : thierry.florac@onf.fr Tél. : +33 01.40.19.59.64 Fax. : +33 01.40.19.59.85
I'm guessing that AJ's solution is the best to implement. What I did to solve this problem is simply create a few crons on the server that each do a mechanize (http://wwwsearch.sourceforge.net/mechanize/) http call to a specific location in Zope which basically acts as a private API: when called, it executes a function that triggers whatever needs to happen. I hard-coded a check that the source IP must be the specific internal address of the server Zope runs on. That way I know that the functions can't be called from the outside. Not the best solution, and I wouldn't really recommend it to someone else, but it's easy and it works for me. - Thibaud On Mon, Feb 16, 2009 at 12:50 PM, Thierry Florac <thierry.florac@onf.fr>wrote:
Le lundi 16 février 2009 à 16:59 +0100, Marco Bizzarri a écrit :
Hi all.
A little of background, before.
I need to run some tasks, inside a zope environment, in a periodic way. Even though I could resort to using cron and wget, I do not like the solution too much, also because it requires me to rely on something completly external to the application to schedule the task itsel (I need to update the cron to change how often a job is run... ).
Now, I can see I can run a task using zopectl run + a script. My script would therefore be something like:
while True: do something sleep(for sometime)
of course, there are dozen of ways to write this in a better way, but that is not the problem. My problem is understanding if it is possible to run such a script via the zdaemon. Can anyone shred some light on this topic?
Hi,
I don't know if it's the best way, but I've implemented a "cron like" task base class for my Zope-2.9 instance, which : - is thread based - can launch operations in a "cron like" way - can act as the user of your choice.
It doesn't actually provide any user interface to define task scheduling, but the main base class could probably be used as a good starting point ; at least, it works ;-). I can send you the source code on request...
Thierry Florac -- Chef de projet intranet/internet Office National des Forêts - Département Informatique 2, Avenue de Saint-Mandé 75570 PARIS Cedex 12 Mél : thierry.florac@onf.fr Tél. : +33 01.40.19.59.64 Fax. : +33 01.40.19.59.85
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Thibaud Morel l'Horset wrote:
What I did to solve this problem is simply create a few crons on the server that each do a mechanize (http://wwwsearch.sourceforge.net/mechanize/) http call to a specific location in Zope which basically acts as a private API: when called, it executes a function that triggers whatever needs to happen. I hard-coded a check that the source IP must be the specific internal address of the server Zope runs on. That way I know that the functions can't be called from the outside.
This is all extremely fragile and generally not a good idea. Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
On Mon, Feb 16, 2009 at 6:50 PM, Thierry Florac <thierry.florac@onf.fr> wrote:
Hi,
I don't know if it's the best way, but I've implemented a "cron like" task base class for my Zope-2.9 instance, which : - is thread based - can launch operations in a "cron like" way - can act as the user of your choice.
It doesn't actually provide any user interface to define task scheduling, but the main base class could probably be used as a good starting point ; at least, it works ;-). I can send you the source code on request...
Thierry Florac
Hi, Thierry... thanks for sharing your ideas with me :) I will be glad to look at your code, but first: which licence? Sorry, but I do not have complete freedom on this, so... -- Marco Bizzarri http://notenotturne.blogspot.com/ http://iliveinpisa.blogspot.com/
Marco Bizzarri wrote:
Is there a better way to run such tasks in Zope 2 environments?
Have a look at Stepper: http://www.simplistix.co.uk/software/zope/stepper ...and then actually *use* cron to trigger stepper ;-) Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
On Tue, Feb 17, 2009 at 6:48 PM, Chris Withers <chris@simplistix.co.uk> wrote:
Marco Bizzarri wrote:
Is there a better way to run such tasks in Zope 2 environments?
Have a look at Stepper:
http://www.simplistix.co.uk/software/zope/stepper
...and then actually *use* cron to trigger stepper ;-)
Chris
-- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
Thanks, Chris, but I do not want to use cron... also because I can end in environments where there is no cron ;) -- Marco Bizzarri http://notenotturne.blogspot.com/ http://iliveinpisa.blogspot.com/
Marco Bizzarri wrote:
Thanks, Chris, but I do not want to use cron...
Why not? Why re-invent the wheel in a more fragile and less tested way?
also because I can end in environments where there is no cron ;)
Such as? On *nix, you have cron. On MacOS, you have cron. On Windows, you have Schedules Tasks. On all posix systems you have 'at'. So where are these environments where you don't have cron or an equivalent? Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
participants (5)
-
Andreas Jung -
Chris Withers -
Marco Bizzarri -
Thibaud Morel l'Horset -
Thierry Florac