[Twisted-Python] _dumbwin32proc and PIPE_NOWAIT

Manlio Perillo manlio_perillo at libero.it
Fri Sep 29 17:01:06 MDT 2006


From the msdn:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ipc/base/setnamedpipehandlestate.asp

"""PIPE_NOWAIT 0x00000001 	

Nonblocking mode is enabled. In this mode, ReadFile, WriteFile, and
ConnectNamedPipe always return immediately. Note that nonblocking mode
is supported for compatibility with Microsoft® LAN Manager version 2.0
and should not be used to achieve asynchronous input and output (I/O)
with named pipes.
"""


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

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


P.S.2:
From:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ipc/base/anonymous_pipe_operations.asp

"""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.
"""

And from:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/inheritance.asp

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

* Open handles returned by the CreateFile function. This includes
handles to files, console input buffers, console screen buffers, named
pipes, serial communication devices, and mailslots.

* Open handles to process, thread, mutex, event, semaphore, named-pipe,
anonymous-pipe, and file-mapping objects. These are returned by the
CreateProcess, CreateThread, CreateMutex, CreateEvent, CreateSemaphore,
CreateNamedPipe, CreatePipe, and CreateFileMapping functions, respectively.
"""

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?

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").

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




Regards  Manlio Perillo





More information about the Twisted-Python mailing list