See response below.<br><br>
<div><span class="gmail_quote">On 7/11/05, <b class="gmail_sendername">Jp Calderone</b> &lt;<a href="mailto:exarkun@divmod.com">exarkun@divmod.com</a>&gt; wrote:</span> 
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">On Mon, 11 Jul 2005 10:52:14 -0500, Justin Johnson &lt;<a href="mailto:justinjohnson@gmail.com">justinjohnson@gmail.com
</a>&gt; wrote:<br>&gt;I am attempting to add spawnProcess to iocpreactor. In order to begin this<br>&gt;task I've had to do a lot of reading on Windows network programming,<br>&gt;specifically the various Windows I/O methods, to attempt to understand what
<br>&gt;win32eventreactor and iocpreactor are doing, and also just increase my<br>&gt;understanding of how reactors work in general. To understand the various<br>&gt;Winsock 2 methods that both of these reactors rely upon, I read chapters 1-5
<br>&gt;of Network Programming for Microsoft Windows[1].<br>&gt; Before actually attempting to add spawnProcess, I would like to present how<br>&gt;I think iocpreactor works and how I think I should add spawnProcess, and<br>
&gt;hopefully be corrected or confirmed in my understanding. If I'm too vague<br>&gt;there's a good chance it's because I don't understand it very well. Please<br>&gt;feel free to point out things that you might think are obvious but aren't
<br>&gt;sure I understand.<br>&gt; How iocpreactor works<br>&gt;---------------------------------<br>&gt;<br>&gt; [snip]<br>&gt;<br>&gt;&nbsp;&nbsp;How to add spawnProcess<br>&gt;---------------------------------------<br>&gt;<br>&gt;&nbsp;&nbsp; 1. Create the processes via Windows APIs and associate their
<br>&gt;&nbsp;&nbsp; stdout/err with with the IOCP via CreateIoCompletionPort calls.<br>&gt;&nbsp;&nbsp; 2. Close stdin.<br><br>Why close stdin?&nbsp;&nbsp;How will you write to the spawned process?</blockquote>
<div>&nbsp;</div>
<div>I see, so I won't close stdin and people can do that in their ProcessProtocol in connectionMade or something if they want.</div><br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">&gt;&nbsp;&nbsp; 3. Notify the ProcessProtocol via protocol.makeConnection (not sure<br>&gt;&nbsp;&nbsp; why, looking at win32eventreactor)
<br><br>makeConnection is the method that's actually part of IProtocol (even though ProcessProtocol doesn't implement IProtocol, it still adheres to its API in this regard).&nbsp;&nbsp;Generally, all it does is set the .transport attribute on the protocol instance and then call connectionMade.&nbsp;&nbsp;This might seem pointless in the case of processes, but since it maintains consistency with other kinds of transports, it is useful.
</blockquote>
<div>&nbsp;</div>
<div>&nbsp;So the Process class is the transport?&nbsp; In win32eventreactor, 3 threads are started that loop on reading stdout and stderr and writing data from the outQueue to stdin.&nbsp; It seems to me that I would not use these threads, but instead have each of these 3 file handles associated with the IOCP.&nbsp; Then the methods defined in 
ops.py would be used to handle events on those handles, resulting in transport methods being called.&nbsp; These transport methods would be methods on the Process class, which would result in methods on a single instance of the ProcessProtocol being called.&nbsp; This single instance of the ProcessProtocol would be shared by all of the 3 file handles.&nbsp; Am I understanding correctly?&nbsp; Are write and loseConnection the only methods the Process would need to implement from ITransport?
</div><br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">&gt;&nbsp;&nbsp; 4. Receive data from stdout/err via the completion port by calling<br>&gt;&nbsp;&nbsp; GetQueuedCompletionStatus from within doIteration. Is this really possible?
<br>&gt;&nbsp;&nbsp; ProcessProtocol's methods won't get called appropriately by letting the<br>&gt;&nbsp;&nbsp; existing callbacks in ops.py make calls to the transport (e.g.<br>&gt;&nbsp;&nbsp; connectionDone, readDone)?<br>&gt;<br>&gt;&nbsp;&nbsp;Thanks for your help.
<br>&gt;Justin<br>&gt; [1] <a href="http://www.amazon.com/exec/obidos/ASIN/0735615799">http://www.amazon.com/exec/obidos/ASIN/0735615799</a><br>&gt;<br><br>Jp<br><br>_______________________________________________<br>Twisted-Python mailing list
<br><a href="mailto:Twisted-Python@twistedmatrix.com">Twisted-Python@twistedmatrix.com</a><br><a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
</a><br></blockquote></div><br>