Stuff
public text v1 · immutabledef countOpenFileDescriptors():
import resource
soft, hard = resource.getrlimit(resource.RLIMIT_NOFILE)
n = 0
for fd in range(soft):
try:
os.fstat(fd)
n += 1
except OSError, e:
if e.errno != errno.EBADF:
n += 1
except Exception:
pass
return n