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

Claudio tracker at bugs.pypy.org
Tue Jun 4 20:10:19 CEST 2013


Claudio <klaussfreire at gmail.com> added the comment:

Indeed, it seems somewhat specific to my case, simpler applications don't
trigger the bug. But I managed to reduce it to this:

>>>> import os, urllib2
>>>> req = """{"imp": [{"h": 50, "battr": ["9", "10", "12"], "api": 3, "w": 320,
"instl": 0, "impid": "5d6dedf3-17bb-11e2-b5c0-1040f38b83e0"}]""" * 10
>>>> r = urllib2.Request("http://localhost:8000/bogus?src=1", req)
>>>> u = urllib2.urlopen(r)
>>>> v = u.read()
>>>> u.close()
>>>> os.system("ls -alh /proc/%d/fd/*" % os.getpid())
lrwx------ 1 claudiofreire users 64 Jun  4 15:08 /proc/26203/fd/0 -> /dev/pts/5
lrwx------ 1 claudiofreire users 64 Jun  4 15:08 /proc/26203/fd/1 -> /dev/pts/5
lrwx------ 1 claudiofreire users 64 Jun  4 15:08 /proc/26203/fd/2 -> /dev/pts/5
lrwx------ 1 claudiofreire users 64 Jun  4 15:08 /proc/26203/fd/3 ->
socket:[2086998]
lrwx------ 1 claudiofreire users 64 Jun  4 15:08 /proc/26203/fd/5 -> /dev/pts/5
lrwx------ 1 claudiofreire users 64 Jun  4 15:08 /proc/26203/fd/6 -> /dev/pts/5
0
>>>> 


Run the attached tornado application (not sure it's specific to tornado, but I
did manage to reproduce it with tornado)

Notice that tornado can be running in CPython or pypy in my test, both work
fine. It's in urllib2 the leak.

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


More information about the pypy-issue mailing list