Help needed with Windows Service in Python
Ian
hobson42 at gmaiil.com
Thu Sep 2 15:38:35 EDT 2010
More information about the Python-list mailing list
Thu Sep 2 15:38:35 EDT 2010
- Previous message (by thread): Help needed with Windows Service in Python
- Next message (by thread): Help needed with Windows Service in Python
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 02/09/2010 20:06, Edward Kozlowski wrote: > On Sep 2, 10:22 am, Ian Hobson<i... at ianhobson.co.uk> wrote: >> Hi All, >> >> I am attempting to create a Windows Service in Python. >> >> I have the framework (from Mark Hammond and Andy Robinason's book) >> running - see below. It starts fine - but it will not stop. :( >> >> net stop "Python Service" >> >> and using the services GUI both leave the services showing it as "stopping" >> >> I guess this means SvcStop is called but it is not enough to get it out >> of the machine. >> >> Does anyone know why not? >> >> Python 2.7 with win32 extensions, sunning on Windows 7. >> >> Many thanks >> >> Ian >> >> the (complete) source code is >> #!/usr/bin/env python >> # coding=utf8 >> # service.py = testing services and Named pipes >> # >> import win32serviceutil >> import win32service >> import win32event >> class PythonService(win32serviceutil.ServiceFramework): >> _svc_name_ = "Python Service" >> _svc_display_name_ = "Test Service in Python" >> 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) >> wind32event.SetEvent(self.hWaitStop) >> def SvcDoRun(self): >> win32event.WaitForSingleObject(self.hWaitStop,win32event.INFINITE) >> if __name__ == '__main__': >> win32serviceutil.HandleCommandLine(PythonService) > Looks to me like there may be a typo in your code. > > You probably meant win32event.SetEvent(self.hWaitStop), not > wind32event. > > Regards, > -Edward Kozlowski A huge big thank you Edward. That was the problem. Regards Ian
- Previous message (by thread): Help needed with Windows Service in Python
- Next message (by thread): Help needed with Windows Service in Python
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list