[python-win32] Python-based Windows service: Subcommand works with "debug", but hangs under "start"

Jens Vagelpohl jens at dataflake.org
Mon Feb 20 16:26:05 CET 2012


Hi all,

I've written a Windows service based on win32serviceutil.ServiceFramework. The service per se is running just fine. I am testing it on Windows Server 2003.

When starting, the service uses the win32process.CreateProcess to start a process:

win32process.CreateProcess(None, <CMDLINE>, None, None, 0, 0, None, <WORKINGDIR>, win32process.STARTUPINFO())

This process is a new Python interpreter which allows me better control over setting up the the environment (e.g. PYTHONPATH) in order to invoke code outside of the system's PYTHONPATH. The service is using win32event.WaitForMultipleObjects to keep track of this process. That part works fine as well.

Where I am failing is an attempt to spawn a subprocess from my service's new Python process. I have tried all kinds of parameter combinations for subprocess.call and subprocess.check_output, and tried win32process.CreateProcess as well. It all works fine when running my service from the command line using the "debug" flag. But when the service is started with the "start" flag (or from the Service Manager), the command line process I am spawning last always hangs. Funny detail: The same code works fine under Windows 7.

Can anyone show me how to debug the hanging subprocess?

Thanks!

jens

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 203 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://mail.python.org/pipermail/python-win32/attachments/20120220/b8cf12fa/attachment.pgp>


More information about the python-win32 mailing list