Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
281b551a
Commit
281b551a
authored
Apr 20, 2010
by
Senthil Kumaran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Issue8460: Victor's patch to add timeout in test_urllib2net test_urls.
parent
ac4b7ada
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
4 deletions
+16
-4
Lib/test/test_urllib2net.py
Lib/test/test_urllib2net.py
+16
-4
No files found.
Lib/test/test_urllib2net.py
View file @
281b551a
...
...
@@ -7,6 +7,9 @@ from test.test_urllib2 import sanepathname2url
import
socket
import
urllib2
import
os
import
sys
TIMEOUT
=
60
# seconds
def
_retry_thrice
(
func
,
exc
,
*
args
,
**
kwargs
):
...
...
@@ -167,18 +170,27 @@ class OtherNetworkTests(unittest.TestCase):
req
=
expected_err
=
None
debug
(
url
)
try
:
f
=
urlopen
(
url
,
req
)
f
=
urlopen
(
url
,
req
,
TIMEOUT
)
except
EnvironmentError
,
err
:
debug
(
err
)
if
expected_err
:
msg
=
(
"Didn't get expected error(s) %s for %s %s, got %s: %s"
%
(
expected_err
,
url
,
req
,
type
(
err
),
err
))
self
.
assertIsInstance
(
err
,
expected_err
,
msg
)
except
urllib2
.
URLError
as
err
:
if
isinstance
(
err
[
0
],
socket
.
timeout
):
print
>>
sys
.
stderr
,
"<timeout: %s>"
%
url
continue
else
:
raise
else
:
try
:
with
test_support
.
transient_internet
():
buf
=
f
.
read
()
f
.
close
()
debug
(
"read %d bytes"
%
len
(
buf
))
except
socket
.
timeout
:
print
>>
sys
.
stderr
,
"<timeout: %s>"
%
url
f
.
close
()
debug
(
"******** next url coming up..."
)
time
.
sleep
(
0.1
)
...
...
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