RLIMIT_NOFILE limit

pylist 361
fdb = []
for i in xrange(10000):
    try:
        fdb.append(open('test_max.py', 'r'))
    except Exception, err:
        print "Max open files without changing settings: %s" % i
        break
fdb = []

import resource
soft, hard = resource.getrlimit(resource.RLIMIT_NOFILE)
print "Current RLIMIT_NOFILE limit:", soft, hard, "Changing to 3000..."
resource.setrlimit(resource.RLIMIT_NOFILE, (3000, hard))

fdb = []
for i in xrange(10000):
    try:
        fdb.append(open('test_max.py', 'r'))
    except Exception, err:
        print "Max open files after changing settings: %s" % i
        break
登录发表评论

桂公网安备 45122402000014号