Help needed with Windows Service in Python

Ian Hobson ian at
Thu Sep 2 17:22:04 CEST 2010

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


the (complete) source code is
#!/usr/bin/env python
# coding=utf8
#  = 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):
     self.hWaitStop = win32event.CreateEvent(None,0,0,None)
   def SvcStop(self):
   def SvcDoRun(self):
if __name__ == '__main__':

More information about the Python-list mailing list