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

Mark Hammond skippy.hammond at gmail.com
Tue Feb 21 00:56:59 CET 2012


I guess it depends on what that child process does.  Services run on a 
different desktop, so any UI (eg, message box or similar) or attempts to 
read from stdin etc will make it appear to have hung.  Using a windows 
debugger (or even "process explorer" from the MS SysInternals team) 
might give you the name of the function the "hanging" thread is in which 
may give you some clues...

Mark

On 21/02/2012 2:26 AM, Jens Vagelpohl wrote:
> 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
>
>
>
>
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32



More information about the python-win32 mailing list