I tried to implement this:<br><br>parent_conn, child_conn = Pipe()<br><br>f = defer.Deferred()<br>f = threads.deferToThread(start_test.main_func, SCRIPT_PATH, TEMP_OUTPUT_PATH, self.output_name, child_conn)<br><br>response = parent_conn.recv()<br>
print response //prints like: initialization done<br>
self.transport.write(response)<br>
<br>response = parent_conn.recv()<br>
print response // configuration done<br>
self.transport.write(response)<br><br>But get the same output ie all status messages concatenated and sent at once.!<br><br>[Do we need to put some deffered/callback  mechanism on parent_conn.recv() ??<br>as that is the call blocking the thread waiting for reading.]<br>
<br>Any ideas ? How is such stuff done in twisted servers??<br><br>Naman<br><br><br><div class="gmail_quote">On Tue, Oct 27, 2009 at 7:03 AM, Nathan <span dir="ltr">&lt;<a href="mailto:nathan.stocks@gmail.com">nathan.stocks@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div></div><div class="h5">On Mon, Oct 26, 2009 at 11:44 PM, naman jain &lt;<a href="mailto:namanvit@gmail.com">namanvit@gmail.com</a>&gt; wrote:<br>

&gt; Hi,<br>
&gt;<br>
&gt; I have a client server model in twisted, where the server spawns a thread (<br>
&gt; basically a test script in python that runs for about 20 mins)<br>
&gt; I want to track the progress of the thread, and send the progress to the<br>
&gt; client back<br>
&gt;<br>
&gt; So, I write something like this in my server:<br>
&gt;<br>
&gt; parent_conn, child_conn = Pipe()<br>
&gt; thread = Process(target = start_test.main_func, args=(SCRIPT_PATH,<br>
&gt; TEMP_OUTPUT_PATH, self.output_name, child_conn))<br>
&gt; thread.start()<br>
&gt;<br>
&gt; response = parent_conn.recv()<br>
&gt; print response //prints like: initialization done<br>
&gt; self.transport.write(response)<br>
&gt;<br>
&gt;<br>
&gt; response = parent_conn.recv()<br>
&gt; print response // configuration done<br>
&gt; self.transport.write(response)<br>
&gt;<br>
&gt; .<br>
&gt; .<br>
&gt; .<br>
&gt;<br>
&gt; thread.join()<br>
&gt;<br>
&gt;<br>
&gt; But the transport.write calls don&#39;t send at the same time. instead they wait<br>
&gt; for the thread to finish (coz of thread.join) and then append all the<br>
&gt; response and send it back; like &quot;initialization doneconfiguration<br>
&gt; done...done&quot;<br>
&gt; thereby defeating the purpose of creating a thread.<br>
&gt;<br>
&gt; How do I give the control to the reactor to write the data back, and still<br>
&gt; keep the thread running?<br>
&gt; or is there any other way these kinda of progress can be tracked ?<br>
&gt; I am kinda stuck with this :(<br>
<br>
</div></div>I&#39;m no expert with threads, but I don&#39;t see any deferToThread in<br>
there, which is what people on this list tend to mention whenever<br>
threading comes up.  Perhaps you need to switch to the &quot;twisted way&quot;<br>
to create your thread?<br>
<br>
<a href="http://twistedmatrix.com/documents/8.2.0/api/twisted.internet.threads.html" target="_blank">http://twistedmatrix.com/documents/8.2.0/api/twisted.internet.threads.html</a><br>
<font color="#888888"><br>
~ Nathan<br>
</font><div><div></div><div class="h5"><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" target="_blank">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python</a><br>
</div></div></blockquote></div><br>