[Zope-Coders] Signal forwarding

Guido van Rossum guido@python.org
Thu, 10 Oct 2002 08:45:08 -0400


> > > http://www.zope.org//Wikis/DevSite/Proposals/CleanShutdown
> > > 
> > > It would be worth coordinating these changes to avoid simplifying
> > > the same thing twice.
> > 
> > I see zero hints on how you & Tres plan to implement this (and
> > CleanSignalHandling).  Any elaborations?
> 
> CleanSignalHandling is already implemented:
> 
>   - ZEO storage servers have had signal handling in place (in some
>     form at least) for over two years now (see Jim's comment on v. 1.8
>     of ZEO/ZEO/start.py).

That says:

----------------------------
revision 1.8
date: 2000/08/10 19:55:27;  author: jim;  state: Exp;  lines: +45 -15
Fixed: the -S option didn't allow a space between the option and it's
argument and didn't work with FileStorages.

The -S option allows you to specify a module variable name that is
different from the storage name.  You can now include a '.py' suffix
in the module name, if you must.
----------------------------

which doesn't seem relevant to the discussion.

I've looked at the ZEO StorageServer's signal handlers in detail, and
while it is well-intentioned, it is naive in its implementation.
An enormous amount of work is done inside the signal handler, and
(with Jeremy) I found at least one place where it can deadlock if the
signal arrives in the midst of a transaction.

This is NOT what I would call "clean" signal handling.

>   - Zope's implementation landed on the head back in June (v. 1.68
>     of Zope/z2.py), after some time on a branch, and has been tweaked
>     a couple of times since.

I expect it has similar problems.

Signal handlers aren't safe places to do work.  Signal handlers should
set a global "stop now" flag and nothing else; the main loop should
watch that flag and take appropriate action.

--Guido van Rossum (home page: http://www.python.org/~guido/)