I recently noted that urllib2.urlopen (...) for http:// urls
does not make an explicit call to close the underlying
HTTPConnection socket once the data from the socket is read.
This might not be required since the garbage collector will
close & collect open sockets that are not closed, but it might
cause the system to run out of socket memory if there are
multiple threads, each opening a socket and the gc not running
in between.
This specifically happens in my HarvestMan program which uses
multiple threads to achieve fast offline web downloads.
A patch to fix this in urllib2.py would be nice.
Thanks
-Anand 3 2621
Anand Pillai wrote: I recently noted that urllib2.urlopen (...) for http:// urls does not make an explicit call to close the underlying HTTPConnection socket once the data from the socket is read.
This might not be required since the garbage collector will close & collect open sockets that are not closed, but it might cause the system to run out of socket memory if there are multiple threads, each opening a socket and the gc not running in between.
This specifically happens in my HarvestMan program which uses multiple threads to achieve fast offline web downloads.
A patch to fix this in urllib2.py would be nice.
Thanks
-Anand
In which case you'd be well advised to add this as a bug report on
Sourceforge, as that is the only way to guarantee it will come to (and
stay in) the developers' attention.
It isn't that hard to do.
regards
Steve py*******@Hotpo p.com (Anand Pillai) writes: I recently noted that urllib2.urlopen (...) for http:// urls does not make an explicit call to close the underlying HTTPConnection socket once the data from the socket is read.
This might not be required since the garbage collector will close & collect open sockets that are not closed, but it might cause the system to run out of socket memory if there are multiple threads, each opening a socket and the gc not running in between.
This specifically happens in my HarvestMan program which uses multiple threads to achieve fast offline web downloads.
Does this cause trouble in your app?
I tried using urllib2 with threads a while back, and failed miserably.
Do you reckon the problem you've found could cause deadlock? Seems
unlikely, but I was at the point of having to read the threading
module's code to get any further with my deadlock bug, so I'm
clutching at straws...
A patch to fix this in urllib2.py would be nice.
if-wishes-were-horses-then-beggars-would-ride-<wink>-ly y'rs
John
Steve Holden <sh*****@holden web.com> writes:
[...] A patch to fix this in urllib2.py would be nice. Thanks -Anand
In which case you'd be well advised to add this as a bug report on Sourceforge, as that is the only way to guarantee it will come to (and stay in) the developers' attention.
It isn't that hard to do.
Steve's right that it's not hard to do.
Unfortunately, since people who actually fix bugs (ie. Martin von
Loewis <0.8 wink>) are in short supply, that doesn't guarantee that it
will come to anybody's attention. Of course, you have a *vastly*
higher chance of getting a bug fixed if you provide a patch with
appropriate docs and test code to go with it.
John This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Derek Fountain |
last post by:
I just tried this:
>>> import urllib2
>>> urllib2.urlopen( "https://passenger.ssc.com/~dmarti/contrib-faq/" )
It sits forever. Loading that URL in a normal browser gets me a popup asking
about server certificate authenticity, which presumably is what urllib2 is
blocking at.
How can I prepare my code for this eventuality and ensure it doesn't block?
|
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 #80 and line # 38 are
the first line offenders.
--> --> -->
|
by: Pascal |
last post by:
Hello,
I want to acces my OWA (Outlook Web Acces - http Exchange interface)
server with urllib2 but, when I try, I've always a 401 http error.
Can someone help me (and us)?
Thanks.
here's my pyscript:
|
by: Dan |
last post by:
Does anybody know how to control the source IP address (IPv4) when
using the urllib2 library? I have a Linux box with several IP
addresses in the same subnet, and I want to simulate several
individuals within that subnet accessing web pages independently. I
need the functionality of urllib2 because there will be redirects and
other HTTP-type functions to implement. It would be nice if I could
create (and bind) sockets myself and then...
|
by: Lenard Gunda |
last post by:
Hi,
I have the following problem when I am working with sockets in C#. I do not
remember running into the same problem some while ago, when working with
sockets from C++ (using native code, not managed).
I create a server socket, and then listen on it. I then accept a new
connection from that server socket. If I now close the server socket, it
also closes the accepted connection as well, automatically. This feels
stupid.
| |
by: Funke |
last post by:
Assume that in C#, I create a server socket (listener) and code to start
new threads with each connection using BeginAccept(). After some time,
I have three threads running, each with their own client socket
connection. If I close the listener socket, will the client sockets
also shut down? Or do I need to manually shut these down as well?
|
by: dumbkiwi |
last post by:
I have written a script that uses the urllib2 module to download web
pages for parsing.
If there is no network interface, urllib2 hangs for a very long time
before it raises an exception. I have set the socket timeout with
socket.setdefaulttimeout(), however, where there is no network
interface, this seems to be ignored - presumably, because without a
network interface, there is nothing for the socket module to interact
with.
|
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
url="http://localhost/private/file"
#proxy set up
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |