[Zope-Checkins] CVS: Zope/lib/python/nt_svcutils -
service.py:1.4.2.5
Jeremy Hylton
jeremy at zope.com
Mon Feb 2 16:29:45 EST 2004
Update of /cvs-repository/Zope/lib/python/nt_svcutils
In directory cvs.zope.org:/tmp/cvs-serv2416/lib/python/nt_svcutils
Modified Files:
Tag: jeremy-windows-service-branch
service.py
Log Message:
Add onStop() hook.
Fix bug that prevent service from working if it didn't redirect I/O.
=== Zope/lib/python/nt_svcutils/service.py 1.4.2.4 => 1.4.2.5 ===
--- Zope/lib/python/nt_svcutils/service.py:1.4.2.4 Mon Jan 26 22:02:49 2004
+++ Zope/lib/python/nt_svcutils/service.py Mon Feb 2 16:29:44 2004
@@ -80,6 +80,7 @@
def SvcStop(self):
# Before we do anything, tell the SCM we are starting the stop process.
self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
+ self.onStop()
# stop the process if necessary
try:
win32process.TerminateProcess(self.hZope, 0)
@@ -89,6 +90,10 @@
# And set my event.
win32event.SetEvent(self.hWaitStop)
+ def onStop(self):
+ # A hook for subclasses to override
+ pass
+
def createProcess(self, cmd):
self.start_time = time.time()
if self.capture_io:
@@ -170,9 +175,13 @@
keep_running = True
# Assume that the controlled program isn't expecting anything
# on stdin.
- handles[0].Close()
+ if handles:
+ handles[0].Close()
- waitfor = [self.hWaitStop, self.hZope, handles[1], handles[2]]
+ if handles:
+ waitfor = [self.hWaitStop, self.hZope, handles[1], handles[2]]
+ else:
+ waitfor = [self.hWaitStop, self.hZope]
while 1:
rc = win32event.WaitForMultipleObjects(waitfor, 0,
win32event.INFINITE)
@@ -193,8 +202,9 @@
i = rc - win32event.WAIT_OBJECT_0
if not self.redirect(waitfor[i]):
del waitfor[i]
- handles[1].Close()
- handles[2].Close()
+ if handles:
+ handles[1].Close()
+ handles[2].Close()
return keep_running
def redirect(self, handle):
More information about the Zope-Checkins
mailing list