Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gevent
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gevent
Commits
85e94e89
Commit
85e94e89
authored
Mar 04, 2014
by
Denis Bilenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
concurrent_download.py: update for py3
parent
99411f49
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
2 deletions
+7
-2
examples/concurrent_download.py
examples/concurrent_download.py
+7
-2
No files found.
examples/concurrent_download.py
View file @
85e94e89
...
...
@@ -3,6 +3,7 @@
"""Spawn multiple workers and wait for them to complete"""
from
__future__
import
print_function
import
sys
urls
=
[
'http://www.google.com'
,
'http://www.yandex.ru'
,
'http://www.python.org'
]
...
...
@@ -12,12 +13,16 @@ from gevent import monkey
# patches stdlib (including socket and ssl modules) to cooperate with other greenlets
monkey
.
patch_all
()
import
urllib2
if
sys
.
version_info
[
0
]
==
3
:
from
urllib.request
import
urlopen
else
:
from
urllib2
import
urlopen
def
print_head
(
url
):
print
(
'Starting %s'
%
url
)
data
=
url
lib2
.
url
open
(
url
).
read
()
data
=
urlopen
(
url
).
read
()
print
(
'%s: %s bytes: %r'
%
(
url
,
len
(
data
),
data
[:
50
]))
jobs
=
[
gevent
.
spawn
(
print_head
,
url
)
for
url
in
urls
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment