[python-win32] Python Service error 1053: the service did not respond to the start or control request in a timely fashion
Mark Hammond
mhammond at skippinet.com.au
Sun Jan 18 03:41:30 CET 2009
Don't execute the service without args. You generally want:
MyService install
MyService start
...
MyService stop
Although the 'start' and 'stop' is *normally* done simply by setting
the 'auto-start' properties of the service.
Cheers,
Mark
On Sat, Jan 17, 2009 at 12:35 PM, Richard Zinn <ricozinn at gmail.com> wrote:
>
> Hi, I've implemented the MyService.py example from the py2exe samples directory using Python2.6, on my Windows XP SP2, and I get the error 1052...did not respond in a timely fashion immediately when I run the MyService.py, or the MyService.exe, or if I install it as a service using an NSIS installer script I wrote, and start it using the windows service manager.
> Any ideas? Here is the code reduced to just the essentials:
> import win32serviceutil
> import win32service
> import win32event
> import win32evtlogutil
> class MyService(win32serviceutil.ServiceFramework):
> _svc_name_ = "MyService"
> _svc_display_name_ = "My Service"
> _svc_deps_ = ["EventLog"]
> 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):
> import servicemanager
> log("running")
> win32event.WaitForSingleObject(self.hWaitStop, win32event.INFINITE)
> log("stopped")
>
> if __name__ == '__main__':
> win32serviceutil.HandleCommandLine(MyService)
>
> I've seen other posters with similar problems, but with theirs it doesn't work in the .exe, but in my case it doesn't work when I run the .py either. The traceback in python says:
> > python MyService.py
> Collecting Python Trace Output...
> Traceback (most recent call last):
> File "C:\Python26\Lib\site-packages\win32\lib\win32serviceutil.py", line 399,
> in StartService
> win32service.StartService(hs, args)
> pywintypes.error: (1053, 'StartService', 'The service did not respond to the sta
> rt or control request in a timely fashion.')
>
> Thanks in advance,
> Richard
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32
>
More information about the python-win32
mailing list