Thats awesome. Its time I migrate to 3 :)<br><br><div class="gmail_quote">On Fri, Apr 8, 2011 at 11:29 PM, Raymond Hettinger <span dir="ltr"><<a href="mailto:python@rcn.com">python@rcn.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On Apr 8, 12:25 am, Chris Angelico <<a href="mailto:ros...@gmail.com">ros...@gmail.com</a>> wrote:<br>
> On Fri, Apr 8, 2011 at 5:04 PM, Abhijeet Mahagaonkar<br>
><br>
</div><div class="im">> <<a href="mailto:abhijeet.mano...@gmail.com">abhijeet.mano...@gmail.com</a>> wrote:<br>
> > I was able to isolate that major chunk of run time is eaten up in opening a<br>
> > webpages, reading from them and extracting text.<br>
> > I wanted to know if there is a way to concurrently calling the functions.<br>
><br>
</div><div class="im">> So, to clarify: you have code that's loading lots of separate pages,<br>
> and the time is spent waiting for the internet? If you're saturating<br>
> your connection, then this won't help, but if they're all small pages<br>
> and they're coming over the internet, then yes, you certainly CAN<br>
> fetch them concurrently. As the Perl folks say, There's More Than One<br>
> Way To Do It; one is to spawn a thread for each request, then collect<br>
> up all the results at the end. Look up the 'threading' module for<br>
> details:<br>
><br>
> <a href="http://docs.python.org/library/threading.html" target="_blank">http://docs.python.org/library/threading.html</a><br>
<br>
</div>The docs for Python3.2 have a nice example for downloading multiple<br>
webpages in parallel:<br>
<br>
<a href="http://docs.python.org/py3k/library/concurrent.futures.html#threadpoolexecutor-example" target="_blank">http://docs.python.org/py3k/library/concurrent.futures.html#threadpoolexecutor-example</a><br>
<br>
Raymond<br>
<font color="#888888">--<br>
</font><div><div></div><div class="h5"><a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</div></div></blockquote></div><br>