[Zope] How to create an ansynchronous method
David Pratt
fairwinds at eastlink.ca
Wed Sep 14 00:48:56 EDT 2005
Hi Ron. I found the following trying to follow up a bit on what you
have suggested. I believe it is similar to what you are doing from your
explanation. It may be out of date. I have not attempted to
daemonize a process to date so it would be great if you could look at
this and comment since I need something to work with.
http://mail.python.org/pipermail/python-list/2001-February/030814.html
As far as interacting with Zope, I have done something similar to build
a site remotely from another server but setup https and sent
credentials in the urls. I wonder if there is a way to inject them
into Zope another way since the daemon is on the machine. I think the
ClockServer injects requests into Zope. I believe it is something
similar since credentials still need to be in url to execute something
but requests are not exposed to the web doing this.
Regards,
David
On Wednesday, September 14, 2005, at 12:11 AM, Ron Bickers wrote:
> On Tue September 13 2005 08:16 pm, David Pratt wrote:
>
>> How is it that you send a signal to the long running
>> process?
>
> The long-running process writes a pid file and waits for a SIGUSR1
> signal
> (using Python's signal module). A small External Method, called when
> the
> user submits the form, reads the pid file and sends the signal to the
> process.
>
>> Is the long running process cronned to look for a record in
>> the database or is this starting another server of some type.
>
> It waits for a SIGUSR1 signal from the website, otherwise it's idle.
> That
> way it can begin processing immediately but doesn't have to do any
> periodic
> checking. I do, however, have a cron job that starts it every 15
> minutes in
> case it dies. The process knows if it's already running, so it's safe
> to
> just start it regularly.
>
>> What I need is something like what you are suggesting - wakes up when
>> there is work in the hopper and chugs along until it is done and then
>> goes to sleep (sort of the way a printing queue works). At the same
>> time it would be great if it was something that had a small RAM
>> footprint or ran without consuming any more than X mbs.
>
> The part that waits for the signal is very small, but it loads the
> Reportlab
> modules and reads a bunch of data to do the work, so it can get large
> at
> times. If it were to just call an external program that dies after
> doing
> its work, you could easily keep memory usage low.
>
>> The other
>> problem I have with this is that it needs to do work in Zope itself
>> since the final docs end up as objects. I have just found Chris
>> Wither's product called Stepper. I am not sure it this is for this
>> type
>> of situation or more for cronned maintenance.
>
> I have no idea. Maybe it'll do what you want, but I don't understand
> what it
> really does just from the description. The work I needed to do was
> external
> to Zope anyway (reading data from a MySQL database, building PDFs with
> Reportlab, sending email), so it's actually better that I'm outside of
> it.
>
> When I have to run things in Zope from outside, I run curl with a URL
> of a
> Python Script that does the work. It's a hack, but I've never had a
> problem
> with it. I'm not sure how else you would work in Zope from a process
> outside of Zope.
>
> --
> Ron
>
More information about the Zope
mailing list