[Twisted-Python] Suppressing terminal window from reactor.spawnProcess?

Eric Mangold teratorn at twistedmatrix.com
Fri Feb 2 06:27:40 EST 2007

On Fri, 02 Feb 2007 04:38:44 -0600, Eric Mangold  
<teratorn at twistedmatrix.com> wrote:

> On Fri, 02 Feb 2007 02:00:49 -0600, Steve Freitas <sflist at ihonk.com>  
> wrote:
>> Hi,
>> I'm doing a Twisted app on Windows. As part of its work it uses
>> spawnProcess to temporarily spawn a process to communicate with. When I
>> run the app from the command line in the usual fashion, spawnProcess()
>> goes on and does its thing quietly and nicely. I then turned the Twisted
>> app into a Windows Service, and now when it spawns the process, it opens
>> a terminal window. Any idea how to suppress that? I tried the usePTY
>> argument but of course that ain't supported on Windows.
>> Thanks!
>> Steve
> Unfortunately Twisted doesn't have any way to alter this behavior.
> Processes on Windows will inherit the parent's console by default. So  
> when you run from the command-line it doesn't need to create a new one.
> But when run as a service I suspect that the parent process (Twisted) is  
> created DETACHED, so it doesn't have a console. But when you spawn a new  
> child it just uses the defaults which then gives you a console.
> For what it's worth the win32 API flag of interest is DETACHED_PROCESS  
> documented here: http://msdn2.microsoft.com/en-us/library/ms684863.aspx
> spawnProcess is currently slated for a redesign as per  
> http://twistedmatrix.com/trac/ticket/2415
> I will make sure this concern is address in some form or fashion, but in  
> the mean time you will have to do some work yourself if you really need  
> this feature. Let use know if you get stuck :)

Actually CREATE_NO_WINDOW might be the flag you want. I'm not 100% sure  
w/o running some tests.

Eric Mangold
Twisted/Win32 Co-Maintainer

More information about the Twisted-Python mailing list