Last active
March 5, 2016 12:34
-
-
Save HelloZeroNet/d9bf888693e66a573815 to your computer and use it in GitHub Desktop.
Test and change max open files limit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 sys | |
if sys.platform == "win32": | |
import win32file | |
print "Current maxstdio", win32file._getmaxstdio(), "Changing to 2048..." | |
win32file._setmaxstdio(2048) | |
else: | |
import resource | |
soft, hard = resource.getrlimit(resource.RLIMIT_NOFILE) | |
print "Current RLIMIT_NOFILE limit:", soft, hard, "Changing to 2048..." | |
resource.setrlimit(resource.RLIMIT_NOFILE, (2048, 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment