About Archive Tag Cloud Translations RSS

You are writing a comment about Parallel HTTP Requests in Python, here is a quick summary:

Last week I was doing parallel HTTP Requests in PHP, and it seemed like a crying shame I was doing something in PHP that I had never figured out in Python. Like it often happens, it only takes a couple dozen lines to teach Python this new trick.


You are responding to this comment written by Peter on December 6th 2008, 18:58.

I hacked on this code a bit, mostly just to keep my Python skills up. I tried to eliminate the call to sleep() by using join, and to allow a timeout of None to indicate that it should wait until all urls are fetched.

I also made the threads daemons so that the program wouldn't wait on them to exit, since if no other threads were waiting on them then we don't care about what they're fetching anymore. Oh, and I had to butcher alive_count() to make it compatible with my ancient python2.4

Performance turned out to be comparable, with or without an explicit call to sleep()

http://gist.github.com/33001


Please be aware that comment forms go stale after one hour.





Comments may make use of LifeFlow MarkDown. Raw html will be escaped.


Quick Introduction to LifeFlow MarkDown Syntax

A highlighted code block:

@@ ruby
def a (b, c):
  b * c
end
@@

Other common languages work as well: scheme, python, java, html, etc.

Other markdown syntax:

 ### This is an h3 title
#### This is an h4 title
**this is bold**
*this is italics*

1. This is an
2. ordered list

* And an unordered
* list too

[this is a link](http://www.lethain.com/ "Lethain")