[Zope3-dev] [Fwd: Re: [Zope-Coders] Signal handling]
Steve Alexander
steve@cat-box.net
Fri, 14 Jun 2002 16:54:08 +0100
This is a multi-part message in MIME format.
--------------090402070601090503060606
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
Should this tie into the EventService for Zope 3?
--
Steve Alexander
--------------090402070601090503060606
Content-Type: message/rfc822;
name="Re: [Zope-Coders] Signal handling"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="Re: [Zope-Coders] Signal handling"
X-Sieve: cmu-sieve 1.3
Return-Path: <zope-coders-admin@zope.org>
Received: from mail.python.org (mail.python.org [63.102.49.29])
by sushi.cat-box.net (Postfix) with ESMTP id 79E9D265E7
for <steve@cat-box.net>; Fri, 14 Jun 2002 16:45:15 +0100 (BST)
Received: from localhost.localdomain ([127.0.0.1] helo=mail.python.org)
by mail.python.org with esmtp (Exim 4.04)
id 17ItG3-00029E-00; Fri, 14 Jun 2002 11:45:03 -0400
Received: from exim by mail.python.org with spamc (Exim 4.04)
id 17ItFe-0001qb-00
for zope-coders@zope.org; Fri, 14 Jun 2002 11:44:38 -0400
Received: from smtp.zope.com ([63.100.190.95])
by mail.python.org with esmtp (Exim 4.04)
id 17ItFe-0001qU-00
for zope-coders@zope.org; Fri, 14 Jun 2002 11:44:38 -0400
Received: from machiavelli (machiavelli.digicool.com [192.168.23.47])
by smtp.zope.com (8.11.6/8.11.2) with SMTP id g5EFiDm20622;
Fri, 14 Jun 2002 11:44:13 -0400
From: "Brian Lloyd" <brian@zope.com>
To: "Toby Dickenson" <tdickenson@geminidataloggers.com>,
"Chris McDonough" <chrism@zope.com>, <zope-coders@zope.org>
Subject: RE: [Zope-Coders] Signal handling
Message-ID: <NEBBKMOOINLOHMJBOMPIIEELCDAA.brian@zope.com>
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Priority: 3 (Normal)
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0)
In-reply-to: <200206141131.23518.tdickenson@geminidataloggers.com>
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600
Importance: Normal
X-MailScanner: Found to be clean
X-Spam-Status: No, hits=-6.4 required=5.0 tests=IN_REP_TO,SUBJ_PYTHON_ZOPE,BODY_PYTHON_ZOPE version=2.20
X-Spam-Level:
Sender: zope-coders-admin@zope.org
Errors-To: zope-coders-admin@zope.org
X-BeenThere: zope-coders@zope.org
X-Mailman-Version: 2.0.11 (101270)
Precedence: bulk
List-Help: <mailto:zope-coders-request@zope.org?subject=help>
List-Post: <mailto:zope-coders@zope.org>
List-Subscribe: <http://lists.zope.org/mailman/listinfo/zope-coders>,
<mailto:zope-coders-request@zope.org?subject=subscribe>
List-Id: People with Zope public CVS checkin privileges <zope-coders.zope.org>
List-Unsubscribe: <http://lists.zope.org/mailman/listinfo/zope-coders>,
<mailto:zope-coders-request@zope.org?subject=unsubscribe>
List-Archive: <http://lists.zope.org/pipermail/zope-coders/>
Date: Fri, 14 Jun 2002 12:02:02 -0400
> I have some products that have their own log files, and it would
> be nice to
> reopen those on a USR2 too.
>
> Any objections to the patch in http://collector.zope.org/Zope/430 ?
It seems like it would be good for this to be a more
generalized facility, rather than adding more funny
magic globals.
So I went ahead and did it :)
Chris, I refactored it so that the sig handling code
that was in z2.py is now encapsulated in a singleton
in a new module: SignalHandler.py.
The way it works now, the "standard" signal handlers
that were in z2 are guaranteed to run, but users can
now use the registerHander method to add handlers for
given signals. For example:
from SignalHandler import SignalHandler
import signal
def mySigUsr2Handler():
print 'hi, Im the SIGUSR2 handler!'
SignalHandler.registerHandler(signal.SIGUSR2, mySigUsr2Handler)
The only caveat is that for now you are restricted to
SIGINT, SIGTERM, SIGUSR2 and SIGHUP. That's because
of the way that signal pass-through is hooked up to
zdaemon. The SignalHandler singleton can deal with
any kind of signal, so if we ever care to figure this
out we'll just need to revisit the way that zdaemon is
notified of pass-through signals.
Brian Lloyd brian@zope.com
V.P. Engineering 540.361.1716
Zope Corporation http://www.zope.com
_______________________________________________
Zope-Coders mailing list
Zope-Coders@zope.org
http://lists.zope.org/mailman/listinfo/zope-coders
--------------090402070601090503060606--