Why python has limit for count of file handles? -
i writed simple code test, how files may open in python script:
for in xrange(2000): fp = open('files/file_%d' % i, 'w') fp.write(str(i)) fp.close() fps = [] x in xrange(2000): h = open('files/file_%d' % x, 'r') print h.read() fps.append(h)
and exception
ioerror: [errno 24] many open files: 'files/file_509'
the number of open files limited operating system. on linux can type
ulimit -n
to see limit is. if root, can type
ulimit -n 2048
now program run ok (as root) since have lifted limit 2048 open files
Comments
Post a Comment