[New-bugs-announce] [issue13131] FD leak in urllib2

Valery Khamenya report at bugs.python.org
Sat Oct 8 14:25:53 CEST 2011


New submission from Valery Khamenya <khamenya at gmail.com>:

Explanation from dablitz's comment at https://bugs.pypy.org/issue867 :

<quote>
urllib2 in the stdlib leaks fd's if an exception is raised while opening a connection. The issue occurs due to a socket being opened then an exception being raised before an object with the socket is returned, leaving no way to explicitly close the object. On cpython this would not be an issue as the object would lose all references almost immediately however it lingers around with a proper GC causing FD's to build up if the same condition happens repeatedly (eg a loop/web crawling)

The file enclosed is a script to generate the leakage, to run invok it as follows <python> leak.py

pypy should start leaking FD's and can be see in /proc/<pid of leak.py>/fd

</quote>

Related issues:
http://bugs.python.org/issue3066
http://bugs.python.org/issue1208304
http://bugs.python.org/issue1601399

----------
components: IO, Library (Lib)
files: leak.py
messages: 145166
nosy: Valery.Khamenya
priority: normal
severity: normal
status: open
title: FD leak in urllib2
type: resource usage
versions: Python 2.7
Added file: http://bugs.python.org/file23344/leak.py

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue13131>
_______________________________________


More information about the New-bugs-announce mailing list