Created
September 6, 2019 00:12
-
-
Save carlos-jenkins/beba09db1e7b4639e7e37f33448d56ec to your computer and use it in GitHub Desktop.
Get and set the NOPEN limit (maximum number of open files)
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
from resource import RLIMIT_NOFILE, getrlimit, setrlimit | |
def setfilelimits(limit): | |
soft, hard = getrlimit(RLIMIT_NOFILE) | |
if limit > hard: | |
raise RuntimeError( | |
'Unable to raise open files limit to {}. ' | |
'Hard limit is set to {}'.format( | |
limit, hard, | |
) | |
) | |
setrlimit(RLIMIT_NOFILE, (limit, hard)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment