[Twisted-Python] _dumbwin32proc and PIPE_NOWAIT

glyph at divmod.com glyph at divmod.com
Fri Sep 29 22:38:27 EDT 2006

On Sat, 30 Sep 2006 01:01:06 +0200, Manlio Perillo <manlio_perillo at libero.it> wrote:
>From the msdn:

Yep, it's unfortunate that we were forced to use such an ugly API.  However, the *correct* way to do this is to use IOCP, and good IOCP support has been *years* in the making.  We still haven't got a reliably working IOCP buildbot.

You're welcome to contribute a patch which cleans this up on the select reactor, but frankly I don't se any approach which would be better.

>I really can't believe that win32 support for asynchronous I/O works
>with named pipes but not with anonymous pipes...

Yeah, Windows is pretty terrible.  It's only a problem in some versions, but I forget where and when it was fixed.

>By the way, instead of using a polling, why not to use a separate thread
>that puts data into a DeferredQueue?

Because interrupting a blocked thread is a dangerous and error-prone task.  It was hard enough getting the thing to just work with non-blocking pipe IO.

>"""Anonymous pipes are implemented using a named pipe with a unique
>name. Therefore, you can often pass a handle to an anonymous pipe to a
>function that requires a handle to a named pipe.

The word "often" is the killer there.

>"""A child process can inherit [...]

>So, why not to create a named pipe with an unique name, know to both the
> parent and the child process, as an example using an enviroment variable?

Because that would not be usable as standard output using the usual APIs.  This is not just for running other Twisted-using programs in a subprocess, but any program which attempts to adhere to UNIX conventions around standard IO.

>I think that using named pipes can simplify the _dumbwin32proc.
>Moreover polling a named pipe is not an efficient operation
>(reading the author of "Windows System Programming").

The goal of _dumbwin32proc is obviously not efficiency, it is correctness in a configuration which is not well-supported on Windows.  Why do you think its name begins with "dumb"?

>Lastly, the parent process, after creating a named pipe instance, can
>wait for a client connection using ConnectNamedPipe.

... as long as it can wait for the completion event.  Which it can't, because it's using select().

More information about the Twisted-Python mailing list