Hi the list, I'm on a problem since 2 days now and i don't know where to continu to investigate ... notice i've started python 2 month ago and honestly, i don't know if my problem is pywin32, or py2exe, or pyInstaller (same behavior) or simply my code.
The problem is that i don't have any luck to make a simple Windows Service when my python script is compiled in a full standalone executable. I've tried different version of python (2.4.4, 2.5.1 and 2.5.2) with latests version of theses packages: * python 2.5.2 py2exe-0.6.6.win32-py2.5.exe pywin32-210.win32-py2.5.exe * python 2.4.4 py2exe-0.6.6.win32-py2.4.exe pywin32-210.win32-py2.4.exe I'm on a basic Windows XP SP2, completely up-to-date. Here is the code sample, but notice that the sample provided with py2exe (samples\advanced\MyService.py), and the sample provided with pyWin32 (win32\Demos\service\pipeTestService.py) got the same behavior : import win32service import win32serviceutil #import win32traceutil import time import sys #at this point. We're ready to go. #Put simply, a python windows service inherits from win32serviceutils.ServiceFramework #simply extending that class, sets up all you ever need to do. class aservice(win32serviceutil.ServiceFramework): _svc_name_ = "aservice" _svc_display_name_ = "aservice - It Does nothing" def __init__(self,args): win32serviceutil.ServiceFramework.__init__(self,args) self.isAlive = True def SvcDoRun(self): import servicemanager while self.isAlive: servicemanager.LogInfoMsg("aservice - is alive and well") time.sleep(10) #perhaps must use win32.sleep(10) ? servicemanager.LogInfoMsg("aservice - Stopped") def SvcStop(self): import servicemanager servicemanager.LogInfoMsg("aservice - Recieved stop signal") self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING) self.isAlive = False #this will make SvcDoRun() break the while loop at the next iteration. if __name__ == '__main__': print "lets's start, args are : " print sys.argv win32serviceutil.HandleCommandLine(aservice) #this line sets it all up to run properly. Notice you can enable win32traceutil to see stdout. In this case, open another Dos console an execute python C:\Python2X\Lib\site-packages\win32\lib\win32traceutil.py * Using python: python myService.py -install: install the service as expected python myService.py start: start the service as expected python myService.py -remove: remove the service as expected * Using pyInstaller compiled version myService.exe -install : install the service as expected myService.exe start : don't work myService.exe -remove : remove the service as expected pyInstaller 1.3 with python 2.4 : in the python win32traceutil window, you can see that when you start the service using "myService.exe start", myService.exe is launched twice ! Same behavior using pyInstaller trunk checkout with python 2.5.2 The error is " The service did not respond to the start or control request in a timely fashion " Replacing "myService.exe start" with "sc start aservice" output the same thing. * Using py2exe compiled version Every time, i've got Connecting to the Service Control Manager Traceback (most recent call last): File "boot_service.py", line 173, in ? pywintypes.error: (1063, 'StartServiceCtrlDispatcher', "Le processus de service n'a pas pu se connecter au contr\xf4leur de service.") --------------- I have Windows XP SP2 with latest updates and i didn't try on another box (because i got only one ;) I've tried lot's of different service code, install or remove always work, start never I saw some "if sys.frozen" in pywin32 so i know the code is a little bit different when the program is an executable or when it's launched using python command line, perhaps it can be a way to find the problem if it's a pywin32 problem .. Should be great if somebody can help me on this, thanks in advance, Regards, Franck _______________________________________________ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32