[pypy-issue] [issue867] urllib2 on pypy can leak fd's

Da_Blitz tracker at bugs.pypy.org
Sat Sep 10 17:43:59 CEST 2011


New submission from Da_Blitz <pypy at pocketnix.org>:

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

will be reporting issue upstream and hopefully getting a fix in the standard
library but have opened this ticket to get a patch merged earlier in
modified-2.7 when a patch becomes avalible

thanks goes to vak for reporting this issue and timonato1 for assistance

----------
files: leak.py
messages: 3120
nosy: dablitz, pypy-issue
priority: bug
status: unread
title: urllib2 on pypy can leak fd's

________________________________________
PyPy bug tracker <tracker at bugs.pypy.org>
<https://bugs.pypy.org/issue867>
________________________________________


More information about the pypy-issue mailing list