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

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -