Pls keep your posts on the list - so that others can help and so that others can search for problems/solutions!

----- Original Message ----- From: "Daniel Lopez" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, October 13, 2006 12:13 PM
Subject: zope fork in external method



Jonathan-

I'm emailing you because I saw your post a few months back at:

http://mail.zope.org/pipermail/zope/2006-May/166574.html

I've been doing my best to find answers on existing posts, but to no avail. Perhaps you can send further pointers?

On my system, a user can hit a page that initiates a long database query. If the user hits the stop button and tries to refresh, it messes things up (by interrupting the code upon return of the query), so I came up with a solution that almost works:

I put all the code into an external method, which forks. The parent returns a redirect to a "waiting" throbber page that uses Ajax to poll whether the query is done. The child then goes on to do the hard work.

This is working as desired, with a single exception: zombie child processes. Where can I learn more about forking processes in zope external methods? I've read about the double-fork method, but that hasn't resolved the problem...

A few ideas for reaping dead child processes:

1) implement a SIGCHLD handler

2) when a spawned child process is finished its 'zope processing' have it write its process id to a file (be careful when accessing files, you will need locking to eliminate problems that may be caused by zope's multiple threads) and then have a clean up routine which kills all of the processes listed in the file (this could be an independant clean-up routine which wakes up on a regular basis, or it could be built into the 'spawning' process which does the clean up before it spawns a child).

3) as the last thing it does, have the child process issue a kill -9 system command to kill its own process (I haven't tried this myself, but it may work and it would be simple to implement)

Good luck!

Jonathan


_______________________________________________
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 )

Reply via email to