From: "Richard Zinn" <ricoz...@gmail.com>
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
If SvcDoRun is run in it's own thread, then I suspect the import residing
inside that function. If I remember correctly, Python's import mechanism
causes the thread where the import takes place to deadlock, so you should
always perform an import inside your main thread. Try importing
servicemanager from the top of your script, instead of inside of SvcDoRun.
Then your example should start throwing exceptions because it can't find
'log.' :-)
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32