This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author bohdan
Recipients bohdan
Date 2008-06-09.11:02:21
SpamBayes Score 0.062272012
Marked as misclassified No
Message-id <1213009389.23.0.132424094421.issue3066@psf.upfronthosting.co.za>
In-reply-to
Content
In urllib2.AbstractHTTPHandler.do_open, the following like creates a
circular link:

        r.recv = r.read

[r.read is a bound method, so it contains a reference to 'r'. Therefore,
r now refers to itself.]

If the GC is disabled or doesn't run often, this creates a FD leak.

How to reproduce:

import gc
import urllib2
u = urllib2.urlopen("http://google.com")
s = [ u.fp._sock.fp._sock ]
u.close()
del u
print gc.get_referrers(s[0])
[<socket._fileobject object at 0xf7d42c34>, [<socket object, fd=4,
family=2, type=1, protocol=6>]]

I would expect that only one reference to the socket would exist (the
"s" list itself).

I can reproduce with 2.4; the problems seems to still exist in SVN HEAD.
History
Date User Action Args
2008-06-09 11:03:10bohdansetspambayes_score: 0.062272 -> 0.062272012
recipients: + bohdan
2008-06-09 11:03:09bohdansetspambayes_score: 0.062272 -> 0.062272
messageid: <1213009389.23.0.132424094421.issue3066@psf.upfronthosting.co.za>
2008-06-09 11:02:31bohdanlinkissue3066 messages
2008-06-09 11:02:30bohdancreate