summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorSergey Shepelev <temotor@gmail.com>2013-01-04 04:26:31 +0400
committerSergey Shepelev <temotor@gmail.com>2013-01-04 04:27:30 +0400
commit59cc4955652f4643b8862b1c0d50ea4afc39b18f (patch)
treea482ba5a6b1c99e8e4ab1d0fedb5c06b7e32ab59 /examples
parent24709416393f4ee3d2883b9ccda3cbb0d5b86ee9 (diff)
downloadeventlet-59cc4955652f4643b8862b1c0d50ea4afc39b18f.tar.gz
examples: webcrawler: urls tuple->list + more style fixes
Diffstat (limited to 'examples')
-rw-r--r--examples/webcrawler.py17
1 files changed, 9 insertions, 8 deletions
diff --git a/examples/webcrawler.py b/examples/webcrawler.py
index 50349be..0ffc8b4 100644
--- a/examples/webcrawler.py
+++ b/examples/webcrawler.py
@@ -1,21 +1,21 @@
-#! /usr/bin/env python
+#!/usr/bin/env python
"""
-This is a simple web "crawler" that fetches a bunch of urls using a pool to
+This is a simple web "crawler" that fetches a bunch of urls using a pool to
control the number of outbound connections. It has as many simultaneously open
connections as coroutines in the pool.
The prints in the body of the fetch function are there to demonstrate that the
requests are truly made in parallel.
"""
+import eventlet
+from eventlet.green import urllib2
-urls = (
+
+urls = [
"https://www.google.com/intl/en_ALL/images/logo.gif",
"http://python.org/images/python-logo.gif",
- "http://us.i1.yimg.com/us.yimg.com/i/ww/beta/y3.gif"
-)
-
-import eventlet
-from eventlet.green import urllib2
+ "http://us.i1.yimg.com/us.yimg.com/i/ww/beta/y3.gif",
+]
def fetch(url):
@@ -24,6 +24,7 @@ def fetch(url):
print "done with", url
return url, body
+
pool = eventlet.GreenPool(200)
for url, body in pool.imap(fetch, urls):
print "got body from", url, "of length", len(body)