I feel really puzzled about fellowing code, please help me finger out
what problem here.
import threading
class workingthread(threading.Thread):
def __init__(self):
self.quitEvent = threading.Event()
self.waitTime = 10
threading.Thread.__init__(self)
def run(self):
while not self.quitEvent.isSet():
self.quitEvent.wait(self.waitTime)
def join(self, timeout = None):
self.quitEvent.set()
threading.Thread.join(self, timeout)
import win32serviceutil
import win32event
class testTime(win32serviceutil.ServiceFramework):
_svc_name_ = "testTime"
_svc_display_name_ = "testTime"
_svc_deps_ = ["EventLog"]
def __init__(self, args):
win32serviceutil.ServiceFramework.__init__(self, args)
self.hWaitStop = win32event.CreateEvent(None, 0, 0, None)
self.thread = workingthread()
def SvcStop(self):
win32event.SetEvent(self.hWaitStop)
def SvcDoRun(self):
self.thread.run()
win32event.WaitForSingleObject(self.hWaitStop,
win32event.INFINITE)
self.thread.join()
if __name__ == '__main__':
win32serviceutil.HandleCommandLine(testTime)
each time I got the fellowing result, anyone can point out what's
wrong in it?
E:\code\monitor2>testTime.py debug
Debugging service testTime- press Ctrl+C to stop.
Stopping debug service.
Error 0xC0000003 - The instance's SvcRun() method failed
File "C:\Python24\Lib\site-packages\win32\lib\win32serviceutil.py",
line 785,
in SvcRun
self.SvcDoRun()
File "E:\code\monitor2\testTime.py", line 35, in SvcDoRun
self.thread.run()
File "E:\code\monitor2\testTime.py", line 12, in run
self.quitEvent.wait(self.waitTime)
File "C:\Python24\lib\threading.py", line 348, in wait
self.__cond.wait(timeout)
File "C:\Python24\lib\threading.py", line 222, in wait
_sleep(delay)
exceptions.IOError: (4, 'Interrupted function call')