[python-win32] Passing Args through PythonService.exe

Michael Manfre mmanfre at gmail.com
Wed Jul 10 17:12:53 CEST 2013


I installed the service with the args I wanted and they appeared where I
expected to see them in the service's property dialog (next to the "Path to
executable"). The problem I experienced was that no matter what args were
provided, either installed with the service or provided with the one-off
"start parameters", the sys.argv as seen by my code was a tuple containing
the service's _svc_name_ as set by my win32serviceutil.ServiceFramework
class. I've since given up on using PythonService.exe and am now using
another mechanism.

Regards,
Michael Manfre


On Sun, Jun 30, 2013 at 10:53 PM, Mark Hammond <skippy.hammond at gmail.com>wrote:

> On 21/06/2013 6:06 AM, Michael Manfre wrote:
>
>> Is it possible to pass args through PythonService.exe on to the
>> ServiceFramework class? The only arg that I ever see come through the
>> init is a tuple containing only the _svc_name_. I need to install many
>> services for celery workers and having to create a separate class/file
>> for each environment and queue combination would be painful.
>>
>> I started to dig in to PythonService.cpp, but have yet to find any way
>> of controlling what argv will used with the init.
>>
>
> pythonservice does set sys.argv (see PyService_InitPython() in
> PythonService.cpp) - but note that windows has pretty poor support for
> service command-lines in general - eg, setting "arguments" in the control
> panel applet doesn't persist those arguments - they are one-shot (eg, so
> it's not uncommon for services to manually persist these values in the
> registry when they are seen)
>
> So I suspect you simply aren't seeing the service started with the
> command-line args you expect...
>
> Mark
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20130710/d9f8a554/attachment.html>


More information about the python-win32 mailing list