- Joined
- Jun 18, 2008
- Messages
- 1
- Reaction score
- 0
I have created a simple scirpt and it is working fine when executed from command line, using the following commands
cmcservice.py install
cmcservice.py start
but when this scirpt is converted to executable using either py2exe or pyinstaller, the start function does not work and gets the following error.
------------------
import win32serviceutil, win32service, win32event
class Service(win32serviceutil.ServiceFramework):
_svc_name_ = "mytest"
_svc_display_name_ = "mytestDisplayName"
_svc_description_ = "mytest display name"
def __init__(self, args):
win32serviceutil.ServiceFramework.__init__(self, args)
self.hWaitStop = win32event.CreateEvent(None, 0, 0, None)
def SvcStop(self):
self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
win32event.SetEvent(self.hWaitStop)
def SvcDoRun(self):
pausetime = 60 * 100
while True:
stopsignal = win32event.WaitForSingleObject(self.hWaitStop,
pausetime)
if stopsignal == win32event.WAIT_OBJECT_0: break
self.runOneLoop()
def runOneLoop(self):
import servicemanager
servicemanager.LogInfoMsg('Running')
win32serviceutil.HandleCommandLine(Service)
cmcservice.py install
cmcservice.py start
but when this scirpt is converted to executable using either py2exe or pyinstaller, the start function does not work and gets the following error.
cmcservice.exe start
"Error starting service: The service did not respond to the start or control request in a timely fashion."
Code of the script:"Error starting service: The service did not respond to the start or control request in a timely fashion."
------------------
import win32serviceutil, win32service, win32event
class Service(win32serviceutil.ServiceFramework):
_svc_name_ = "mytest"
_svc_display_name_ = "mytestDisplayName"
_svc_description_ = "mytest display name"
def __init__(self, args):
win32serviceutil.ServiceFramework.__init__(self, args)
self.hWaitStop = win32event.CreateEvent(None, 0, 0, None)
def SvcStop(self):
self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
win32event.SetEvent(self.hWaitStop)
def SvcDoRun(self):
pausetime = 60 * 100
while True:
stopsignal = win32event.WaitForSingleObject(self.hWaitStop,
pausetime)
if stopsignal == win32event.WAIT_OBJECT_0: break
self.runOneLoop()
def runOneLoop(self):
import servicemanager
servicemanager.LogInfoMsg('Running')
win32serviceutil.HandleCommandLine(Service)