Message186556
I see no file descriptor leak myself:
>>> f = urllib2.urlopen("http://www.google.com")
>>> f.fileno()
3
>>> os.fstat(3)
posix.stat_result(st_mode=49663, st_ino=5045244, st_dev=7L, st_nlink=1, st_uid=1000, st_gid=1000, st_size=0, st_atime=0, st_mtime=0, st_ctime=0)
>>> del f
>>> os.fstat(3)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: [Errno 9] Bad file descriptor
Ditto with Python 3:
>>> f = urllib.request.urlopen("http://www.google.com")
>>> f.fileno()
3
>>> os.fstat(3)
posix.stat_result(st_mode=49663, st_ino=5071469, st_dev=7, st_nlink=1, st_uid=1000, st_gid=1000, st_size=0, st_atime=0, st_mtime=0, st_ctime=0)
>>> del f
>>> os.fstat(3)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: [Errno 9] Bad file descriptor
Furthermore, you can use the `with` statement to ensure timely disposal of system resources:
>>> f = urllib.request.urlopen("http://www.google.com")
>>> with f: f.fileno()
...
3
>>> os.fstat(3)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: [Errno 9] Bad file descriptor |
|
Date |
User |
Action |
Args |
2013-04-11 12:39:18 | pitrou | set | recipients:
+ pitrou, jhylton, akuchling, holdenweb, jafo, amaury.forgeotdarc, orsenthil, bwelling, schmir, stephbul, manekcz, nswinton, a.badger, peci, BreamoreBoy, gdub |
2013-04-11 12:39:18 | pitrou | set | messageid: <1365683958.93.0.0641042907783.issue1208304@psf.upfronthosting.co.za> |
2013-04-11 12:39:18 | pitrou | link | issue1208304 messages |
2013-04-11 12:39:18 | pitrou | create | |
|