New submission from Bohdan Vlasyuk <[EMAIL PROTECTED]>:
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.
----------
components: Library (Lib)
messages: 67860
nosy: bohdan
severity: normal
status: open
title: FD leak in urllib2
type: resource usage
versions: Python 2.4
_______________________________________
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue3066>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com