Windows service and pyc files
Gabriel Genellina
gagsl-py2 at yahoo.com.ar
Thu Apr 5 13:14:16 EDT 2007
En Thu, 05 Apr 2007 13:50:16 -0300, Laszlo Nagy
<gandalf at designaproduct.biz> escribió:
> 1. subprocess.Popen cannot redirect stderr and stdout when called from a
> win32 service. This is not documented, and makes debugging almost
> impossible.
Without the patch menctioned in my previous message, you must redirect all
stdin, stdout AND stderr (because the child cannot inherit the handles
from the parent service, as a service has no standard handles assigned
usually) or none of them.
> 2. sys.executable becomes "pythonservice.exe" inside a win32 service.
>
> If I specify r"C:\Python25\python.exe" instead of sys.executable, and
> if I do not specify stdout and stderr parameters for subprocess.Popen,
> then my program starts to work. Here arises the question: how can I
> find r"C:\Python25\python.exe" from inside a win32 service? Can I use
> this:
>
> interpreter = os.path.join( os.path.split(sys.executable),[0],
> os.sep,os.sep,os.sep,'Python.exe' )
I think you meant to write: os.path.join(os.path.split(sys.executable)[0],
os.pardir, os.pardir, os.pardir, 'python.exe')
pythonservice.exe is so Windows-specific that using os.pardir only makes
the code harder to read.
Anyway I'd use os.path.join(sys.prefix, 'python.exe') (sys.prefix would be
C:\Python25 in your case)
--
Gabriel Genellina
More information about the Python-list
mailing list