Cancelling long processes in Zope
How do you stop a long process just triggered, i.e., by accident? One of our apps allows our users to trigger long processes. The way we used to deal with them is to stream response lines so that the user has an idea of what's going on. Nonetheless, some processes aren't worth to watch, so they are simply logged and associated to a mail alert. That's fine so far. As processes can commit transactions regularly on demand, has anyone tried to deal with long processes by means of hacking the Zope threads machinery (or something like that), in order to achieve start, stop and resume commands? Most transactions don't need this, but unawared long procceses use to leak memory and CPU cycles, and they ought to be managed. Any experiences on this subject? Thanks in advance, Ausum
I think it is good practice to deal with long-running processes using a dedicated ZEO client and not to use a website for this. Especially because a long-running request allocates one thread. If you have four threads (default) and a user double or trible-clicks on the same link this will eat up all of your threads. -aj --On 19. August 2005 01:31:28 -0500 Ausum Studio <ausum_studio@hotmail.com> wrote:
How do you stop a long process just triggered, i.e., by accident? One of our apps allows our users to trigger long processes. The way we used to deal with them is to stream response lines so that the user has an idea of what's going on. Nonetheless, some processes aren't worth to watch, so they are simply logged and associated to a mail alert. That's fine so far.
As processes can commit transactions regularly on demand, has anyone tried to deal with long processes by means of hacking the Zope threads machinery (or something like that), in order to achieve start, stop and resume commands? Most transactions don't need this, but unawared long procceses use to leak memory and CPU cycles, and they ought to be managed.
Any experiences on this subject? Thanks in advance,
Ausum _______________________________________________ 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 )
Ausum Studio wrote at 2005-8-19 01:31 -0500:
How do you stop a long process just triggered, i.e., by accident?
If the process is an external process (rather than a thread), you sent it a signal (e.g. a SIGTERM). This may not work in Python 2.3.x for most signal, as these Python versions block signals in the non main thread and this is passed down to processes created by these threads. A process can however reactivate some (or all) signals. Furthermore, the process can still be killed with signal SIGKILL. The bug is fixed in Python 2.4. If the process is rather a thread, it is very difficult to stop it. If the thread is inside a C extension, you cannot abort it without the risk to lose resources or get into inconsistencies (there is no "try: ... finally: ..." in "C"). Python has a C level API function that allows you to deliver an exception to a thread. Once the thread reaches Python again, it will see the exception and process it in the normal way. This might help you in some maybe most cases -- but probably not always... -- Dieter
participants (3)
-
Andreas Jung -
Ausum Studio -
Dieter Maurer