[issue7464] circular reference in HTTPResponse by urllib2
Kristján Valur Jónsson
report at bugs.python.org
Mon Dec 30 12:29:52 CET 2013
Kristján Valur Jónsson added the comment:
No, the socket is actually closed when response's close() method is called. The problem is that the HTTPResponse object, buried deep within the nested classes returned from do_open(), has a circular reference, and _it_ will not go away.
No one is _relying_ on garbage collection in the sense that this is not, I think, designed behaviour, merely an unintentional effect of storing a bound method in the object inance.
As always, circular reference should be avoided when possible since relying on gc is not something to be done lightly.
Now, I think that changing the complicated wrapping at this stage is not possible, but merely replacing the bound method with a weak method might just do the trick.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7464>
_______________________________________
More information about the Python-bugs-list
mailing list