[Spambayes-checkins] spambayes/windows pop3proxy_service.py, 1.7,
1.8
Mark Hammond
mhammond at users.sourceforge.net
Mon Aug 18 00:08:31 EDT 2003
Update of /cvsroot/spambayes/spambayes/windows
In directory sc8-pr-cvs1:/tmp/cvs-serv28770
Modified Files:
pop3proxy_service.py
Log Message:
Updated service that works with the new pop3proxy interface. However,
the interface itself is broken - stop() doesn't stop() the proxy - so
currently the service waits 20 seconds before giving up. This should be
fixed soon :)
Index: pop3proxy_service.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/windows/pop3proxy_service.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** pop3proxy_service.py 18 Aug 2003 04:52:54 -0000 1.7
--- pop3proxy_service.py 18 Aug 2003 06:08:28 -0000 1.8
***************
*** 44,47 ****
--- 44,48 ----
# The spambayes imports we need.
+ import smtpproxy # eek - pop3proxy fails to import unless we do this :(
import pop3proxy
***************
*** 73,81 ****
def __init__(self, args):
win32serviceutil.ServiceFramework.__init__(self, args)
! self.event_stop = threading.Event()
self.thread = None
def SvcStop(self):
! pop3proxy.stop(pop3proxy.state)
def SvcDoRun(self):
--- 74,86 ----
def __init__(self, args):
win32serviceutil.ServiceFramework.__init__(self, args)
! self.event_stopped = threading.Event()
! self.event_stopping = threading.Event()
self.thread = None
def SvcStop(self):
! self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
! self.event_stopping.set()
! pop3proxy.stop(pop3proxy.state)
!
def SvcDoRun(self):
***************
*** 97,106 ****
)
- # Wait for the stop event.
try:
! self.event_stop.wait()
except KeyboardInterrupt:
pass
- # How do we cleanly shutdown the server?
# Write another event log record.
--- 102,121 ----
)
try:
! # Thread running - wait for the stopping event.
! self.event_stopping.wait()
! # Either user requested stop, or thread done - wait for it
! # to actually stop, but reporting we are still alive.
! for i in range(20): # 20 seconds to shut down.
! self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
! self.event_stopped.wait(1)
! if self.event_stopped.isSet():
! break
! print "The service is still shutting down..."
! else:
! # eeek - we timed out - give up in disgust.
! print "The worker failed to stop - aborting it anyway"
except KeyboardInterrupt:
pass
# Write another event log record.
***************
*** 136,141 ****
servicemanager.LogErrorMsg(message)
finally:
! self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
! self.event_stop.set()
if __name__=='__main__':
--- 151,156 ----
servicemanager.LogErrorMsg(message)
finally:
! self.event_stopping.set()
! self.event_stopped.set()
if __name__=='__main__':
More information about the Spambayes-checkins
mailing list