Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #7051 > unrolled thread

Multiple windows services on the same machine

Started byMassi <massi_srb@msn.com>
First post2011-06-05 09:54 -0700
Last post2011-06-06 23:14 +1000
Articles 3 — 3 participants

Back to article view | Back to comp.lang.python


Contents

  Multiple windows services on the same machine Massi <massi_srb@msn.com> - 2011-06-05 09:54 -0700
    Re: Multiple windows services on the same machine Ben Finney <ben+python@benfinney.id.au> - 2011-06-06 09:01 +1000
    Re: Multiple windows services on the same machine Mark Hammond <skippy.hammond@gmail.com> - 2011-06-06 23:14 +1000

#7051 — Multiple windows services on the same machine

FromMassi <massi_srb@msn.com>
Date2011-06-05 09:54 -0700
SubjectMultiple windows services on the same machine
Message-ID<4227ae83-a4a3-46b0-bc25-c5a1d89c08a4@32g2000vbe.googlegroups.com>
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!

[toc] | [next] | [standalone]


#7058

FromBen Finney <ben+python@benfinney.id.au>
Date2011-06-06 09:01 +1000
Message-ID<87vcwj3mtc.fsf@benfinney.id.au>
In reply to#7051
Massi <massi_srb@msn.com> writes:

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

Could you not make the ‘_svc_display_name’ an instance attribute instead
of class attribute?

That is, don't set it as an attribute on the class; instead, set it as
an attribute on the instance during initialisation (the ‘__init__’
method).

-- 
 \         “Smoking cures weight problems. Eventually.” —Steven Wright |
  `\                                                                   |
_o__)                                                                  |
Ben Finney

[toc] | [prev] | [next] | [standalone]


#7082

FromMark Hammond <skippy.hammond@gmail.com>
Date2011-06-06 23:14 +1000
Message-ID<mailman.2487.1307366074.9059.python-list@python.org>
In reply to#7051
On 6/06/2011 2:54 AM, Massi wrote:
> 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'

It is only hard-coded in the HandleCommandLine function - you probably 
just want your own argv parsing and call InstallService directly.

HTH,

Mark

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web