Author bohdan
Recipients bohdan
Date 2008-06-09.11:02:21
SpamBayes Score 0.062272
Marked as misclassified No
Message-id <>
In urllib2.AbstractHTTPHandler.do_open, the following like creates a
circular link:

        r.recv =

[ 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("")
s = [ u.fp._sock.fp._sock ]
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.
Date User Action Args
2008-06-09 11:03:10bohdansetspambayes_score: 0.062272 -> 0.062272
recipients: + bohdan
2008-06-09 11:03:09bohdansetspambayes_score: 0.062272 -> 0.062272
messageid: <>
2008-06-09 11:02:31bohdanlinkissue3066 messages
2008-06-09 11:02:30bohdancreate