Thanks for the detailed reply.<br><br>1.<br>twistd.bat web -n --path=%path% --profile=stats_obj --profiler=cProfile --savestats<br><br>is NOT working for twisted 9.0, --profile and --profiler are both not recognized.<br><br>

2.<br>Sounds like I start to work until all the data are received, as the content are multipart/mixed typed pretty large content, I wanna start to find boundaries and save part of them ASAP. Any clue?<br><br>3. <br>Not only one file, but many files in a multipart/mixed typed body which totally reach a 50MB/s speed.<br>

I made a tests which doing a multipart/mixed request, containing 50000 * 1KB small files. Assume socket.sendall(data) is called<br>at 00:00<br>render_POST start: 00:03<br>process_multipart_content_start: 00:03<br>process_multipart_content_done:00:11<br>

write_all_small_files_in_one_file_start :00:11<br>write_all_small_files_in_one_file_done:00:13<br>respones_given:00:13<br><br>Yes, it takes 13s to get it done. I can only make the process_multipart_content spend less time by combining those small files in several larger files but I still don&#39;t know why 3s are spend before render_POST.<br>

<br><div class="gmail_quote">On Tue, Dec 29, 2009 at 2:02 AM, Reza Lotun <span dir="ltr">&lt;<a href="mailto:rlotun@gmail.com">rlotun@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

Hi,<br>
<div class="im"><br>
&gt; Currently I&#39;m running twisted web via this command line:<br>
&gt; twistd.bat web -n --path=%path%<br>
</div>&gt; ...<br>
<div class="im">&gt; 1. How can I turn on the --profile option?<br>
<br>
</div>You should just be able to do something like:<br>
<br>
    twistd.bat web -n --path=%path% --profile=stats_obj<br>
--profiler=cProfile --savestats<br>
<br>
Then after a duration of time pounding the server with requests you can stop<br>
it and introspect the stats_obj file:<br>
<br>
python<br>
&gt;&gt; import pstats<br>
&gt;&gt; s = pstats.Stats(&#39;stats_obj&#39;)<br>
&gt;&gt; s.sort_stats(&#39;time&#39;).print_stats()<br>
<br>
This will give you an ordered list of functions where the most time has been<br>
spent. It&#39;s also useful to sort by cumulative time. For more information on<br>
how to introspect stats objects see the Python documentation for the pstats<br>
and cProfile module.<br>
<div class="im"><br>
&gt; 2. Any way to know how many millisecond elapsed between &quot;request received&quot;<br>
&gt; and render_POST call?<br>
<br>
</div>You&#39;ll have to measure this yourself I think. A glance at the twisted<br>
codebase informs me:<br>
- In twisted/web/http.py incoming requests are handled by an<br>
HTTPChannel (the protocol from the http server factory)<br>
- Incoming data is processed by the lineReceived method which creates<br>
a Request object<br>
- When all content for a request is received the allContentsReceived<br>
method is invoked, which in turn calls the requestReceived method on<br>
the Request object, which does some internal processing like parsing a<br>
POST-encoded body if there is one. This then calls the process method<br>
on the Request object<br>
- In twisted/web/server.py the Request subclass&#39; process method then<br>
finds the resource being requested and calls the render method<br>
<br>
I imagine you could modify the code in the above places to set global<br>
variables by calling time.time(), and dumping them out at some point.<br>
<div class="im"><br>
&gt; 3. If there are a bunch of files need to be uploaded (say at 50MB/s speed )<br>
&gt; and save by server, Should I write the file directly in render_POST or using<br>
&gt; deferred call?<br>
<br>
</div>Do you mean the server will be *receiving* a file in the HTTP request<br>
body? You can access the request body by looking at request.content<br>
which exposes a File-like API (that is, threat it like you would an<br>
open file in Python).<br>
<br>
If you want to *send* a file via Twisted, take a look at:<br>
<a href="http://twistedmatrix.com/documents/current/core/howto/producers.html" target="_blank">http://twistedmatrix.com/documents/current/core/howto/producers.html</a><br>
and<br>
<a href="http://twistedmatrix.com/documents/9.0.0/api/twisted.protocols.basic.FileSender.html" target="_blank">http://twistedmatrix.com/documents/9.0.0/api/twisted.protocols.basic.FileSender.html</a><br>
<br>
Cheers,<br>
Reza<br>
<br>
--<br>
Reza Lotun<br>
mobile: +44 (0)7521 310 763<br>
email:  <a href="mailto:rlotun@gmail.com">rlotun@gmail.com</a><br>
work:   <a href="mailto:reza@tweetdeck.com">reza@tweetdeck.com</a><br>
twitter: @rlotun<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" target="_blank">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>&gt;: ~<br>