automaticaly increase open file limit on start

This commit is contained in:
Alexander Bersenev
2018-06-11 17:33:57 +05:00
parent 9f11d6d387
commit 8177f2b12d

View File

@@ -11,6 +11,7 @@ import random
import binascii import binascii
import sys import sys
try: try:
from Crypto.Cipher import AES from Crypto.Cipher import AES
from Crypto.Util import Counter from Crypto.Util import Counter
@@ -48,6 +49,16 @@ except ImportError:
return EncryptorAdapter(mode) return EncryptorAdapter(mode)
try:
import resource
soft_fd_limit, hard_fd_limit = resource.getrlimit(resource.RLIMIT_NOFILE)
resource.setrlimit(resource.RLIMIT_NOFILE, (hard_fd_limit, hard_fd_limit))
except (ValueError, OSError):
print("Failed to increase the limit of opened files", flush=True, file=sys.stderr)
except ImportError:
pass
import config import config
PORT = getattr(config, "PORT") PORT = getattr(config, "PORT")
USERS = getattr(config, "USERS") USERS = getattr(config, "USERS")