473,387 Members | 1,678 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

urllib2 spinning CPU on read

Hello All,
I've ran into this problem on several sites where urllib2 will hang
(using all the CPU) trying to read a page. I was able to reproduce it
for one particular site. I'm using python 2.4

import urllib2
url = 'http://www.wautomas.info'
request = urllib2.Request(url)
opener = urllib2.build_opener()
result = opener.open(request)
data = result.read()

It never returns from this read call.

I did some profiling to try and see what was going on and make sure it
wasn't my code. There was a huge number of calls to (and amount of
time spent in) socket.py:315(readline) and to recv. A large amount of
time was also spent in httplib.py:482(_read_chunked). Here's the
significant part of the statistics:

32564841 function calls (32563582 primitive calls) in 545.250
CPU seconds

Ordered by: internal time
List reduced from 416 to 50 due to restriction <50>

ncalls tottime percall cumtime percall filename:lineno(function)
10844775 233.920 0.000 447.440 0.000 socket.py:315(readline)
10846078 152.430 0.000 152.430 0.000 :0(recv)
3 97.330 32.443 544.730 181.577
httplib.py:482(_read_chunked)
10844812 61.090 0.000 61.090 0.000 :0(join)
Also, where should I go to see if something like this has already been
reported as a bug?

Thanks for any help you can give me.

Nov 26 '06 #1
3 1477
"kdotsky" <kd*****@gmail.comwrites:
Hello All,
I've ran into this problem on several sites where urllib2 will hang
(using all the CPU) trying to read a page. I was able to reproduce it
for one particular site. I'm using python 2.4

import urllib2
url = 'http://www.wautomas.info'
[...]
Also, where should I go to see if something like this has already been
reported as a bug?
I didn't try looking at your example, but I think it's likely a bug
both in that site's HTTP server and in httplib. If it's the same one
I saw, it's already reported, but nobody fixed it yet.

http://python.org/sf/1411097
John
Nov 28 '06 #2
I didn't try looking at your example, but I think it's likely a bug
both in that site's HTTP server and in httplib. If it's the same one
I saw, it's already reported, but nobody fixed it yet.

http://python.org/sf/1411097
John
Thanks. I tried the example in the link you gave, and it appears to be
the same behavior.

Do you have any suggestions on how I could avoid this in the meantime?

Nov 28 '06 #3
"kdotsky" <kd*****@gmail.comwrites:
I didn't try looking at your example, but I think it's likely a bug
both in that site's HTTP server and in httplib. If it's the same one
I saw, it's already reported, but nobody fixed it yet.

http://python.org/sf/1411097
John

Thanks. I tried the example in the link you gave, and it appears to be
the same behavior.

Do you have any suggestions on how I could avoid this in the meantime?
Yes: read the recent messages on the tracker I linked to, and apply
the fix I suggest there.
John
Dec 1 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: O. Koch | last post by:
Until now, i know that ftplib doesn't support proxies and that i have to use urllib2. But i don't know how to use the urllib2 correct. I found some examples, but i don't understand them. Is...
2
by: John F Dutcher | last post by:
Can anyone comment on why the code shown in the Python error is in some way incorrect...or is there a problem with Python on my hoster's site ?? The highlites don't seem to show here...but line...
1
by: Alessandro Fachin | last post by:
I write this simply code that should give me the access to private page with htaccess using a proxy, i don't known because it's wrong... import urllib,urllib2 #input url...
3
by: Alexnb | last post by:
Okay, I tried to follow that, and it is kinda hard. But since you obviously know what you are doing, where did you learn this? Or where can I learn this? Maric Michaud wrote:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.