[issue10093] Warn when files are not explicitly closed
Marc-Andre Lemburg
report at bugs.python.org
Fri Oct 29 14:57:53 CEST 2010
Marc-Andre Lemburg <mal at egenix.com> added the comment:
Reposted via the web interface:
>> If you want to monitor resource usage in your application it
>> would be a lot more useful to provide access to the number of
>> currently open FDs
> Agreed it would be useful as well, but please tell that to operating
> system vendors. Python has no way to calculate such a statistic.
At least for Linux, that's not hard and I doubt it is for other OSes.
>>> import os
>>> nfds = len(os.listdir('/proc/%i/fd' % os.getpid()))
>>> print nfds
4
On other Unixes, you can simply use fcntl() to scan all possible FDs
for open FDs.
On Windows you can use one of these functions for the same effect:
http://msdn.microsoft.com/en-us/library/kdfaxaay(v=VS.90).aspx
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue10093>
_______________________________________
More information about the Python-bugs-list
mailing list