A
Austin
class HelloService(win32serviceutil.ServiceFramework):
_svc_name_ = "HelloService"
_svc_display_name_ = "Hello Service"
def __init__(self,args):
win32serviceutil.ServiceFramework.__init__(self,args)
self.hWaitStop = win32event.CreateEvent(None, 0, 0, None)
self.check = 1
def SvcStop(self):
self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
win32event.SetEvent(self.hWaitStop)
self.check = 0
def SvcDoRun(self):
win32event.WaitForSingleObject(self.hWaitStop, win32event.INFINITE)
while True:
CheckPoint('SvcDoRun')
if self.check == 0:
break
if __name__ == '__main__':
win32serviceutil.HandleCommandLine(HelloService)
-----------------------------------------------------------------------
I modified the demo code from Python Programming on Win32.
CheckPoint is a class to open a file and write some words.
But the problem is that no matter how I re-start the service and the
CheckPoint() doesn't work.
Anything wrong?
_svc_name_ = "HelloService"
_svc_display_name_ = "Hello Service"
def __init__(self,args):
win32serviceutil.ServiceFramework.__init__(self,args)
self.hWaitStop = win32event.CreateEvent(None, 0, 0, None)
self.check = 1
def SvcStop(self):
self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
win32event.SetEvent(self.hWaitStop)
self.check = 0
def SvcDoRun(self):
win32event.WaitForSingleObject(self.hWaitStop, win32event.INFINITE)
while True:
CheckPoint('SvcDoRun')
if self.check == 0:
break
if __name__ == '__main__':
win32serviceutil.HandleCommandLine(HelloService)
-----------------------------------------------------------------------
I modified the demo code from Python Programming on Win32.
CheckPoint is a class to open a file and write some words.
But the problem is that no matter how I re-start the service and the
CheckPoint() doesn't work.
Anything wrong?