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

Eric Mangold teratorn at twistedmatrix.com
Fri Feb 2 06:25:58 EST 2007


On Fri, 02 Feb 2007 03:52:36 -0600, Phil Mayers <p.mayers at imperial.ac.uk>  
wrote:

> Steve Freitas 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.
>
> Is the sub-process another python? If so, use "pythonw.exe"

If only! :)

Presumably the only reason he is using Twisted's process spawning API is  
because it connects stdin/out/err to the reactor. Otherwise you should  
just use one of Python's many options.

With pythonw, however, it doesn't create a console and this basically  
means that stdin/out/err are totally useless. Microsoft's C run-time  
connects stdout/err to buffers that go nowhere and as soon as you fill the  
buffers any further writes will fail with a Bad File Descriptor. You can't  
read from stdin at all. Great fun, huh? ;)

-- 
Eric Mangold
Twisted/Win32 Co-Maintainer




More information about the Twisted-Python mailing list