[Zope-Checkins] CVS: Zope/ZServer/PubCore - ZEvent.py:1.7.2.1

Chris McDonough chrism@zope.com
Fri, 15 Mar 2002 14:36:33 -0500


Update of /cvs-repository/Zope/ZServer/PubCore
In directory cvs.zope.org:/tmp/cvs-serv19763/ZServer/PubCore

Modified Files:
      Tag: chrism_logrotate_branch
	ZEvent.py 
Log Message:
Patched up z2.py and some of asyncore to be able to deal with signals.

In this branch, Zope will:

- open and close all of its logfiles upon receving a USR2 signal

- restart "cleanly" upon receiving a HUP signal

- shutdown "cleanly" upon receiving a TERM or INT signal.



=== Zope/ZServer/PubCore/ZEvent.py 1.7 => 1.7.2.1 ===
 
 from ZServer.medusa.thread.select_trigger import trigger
+from ZServer.medusa.asyncore import socket_map
+
+class simple_trigger(trigger):
+    def handle_close(self):
+        pass
+
+the_trigger=simple_trigger()
+
+def Wakeup(thunk=None):
+    try:
+        the_trigger.pull_trigger(thunk)
+    except OSError, why:
+        # this broken pipe as a result of perhaps a signal
+        # we want to handle this gracefully so we get rid of the old
+        # trigger and install a new one.
+        if why[0] == 32: 
+            del socket_map[the_trigger._fileno]
+            global the_trigger
+            the_trigger = simple_trigger() # adds itself back into socket_map
+            the_trigger.pull_trigger(thunk)
 
-Wakeup=trigger().pull_trigger