Multiple windows services on the same machine

Massi massi_srb at msn.com
Sun Jun 5 12:54:58 EDT 2011


Hi everyone, I'm writing a script which implement a windows service
with the win32serviceutil module. The service works perfectly, but now
I would need to install several instances of the same service on my
machine for testing purpose.
This is hard since the service name is hard-coded in the service class
definition:

class MyService(win32serviceutil.ServiceFramework) :
    _svc_name_ = 'MyService'
    _svc_display_name_ = 'Instance ofMyService'

    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)
        sys.stopservice = "true"
        win32event.SetEvent(self.hWaitStop)

    def SvcDoRun(self) :
        #Do something...

So can anyone point me out which is the best way to "parametrize" the
service name? Thanks in advance for your help!



More information about the Python-list mailing list