Rev948, Disable websocket logging, Change max files opened limit on startup

This commit is contained in:
HelloZeroNet 2016-03-06 02:17:58 +01:00
parent dba42f5f5e
commit 2a06cec5c2
4 changed files with 36 additions and 3 deletions

24
src/util/Platform.py Normal file
View file

@ -0,0 +1,24 @@
import sys
import logging
def setMaxfilesopened(limit):
try:
if sys.platform == "win32":
import win32file
maxstdio = win32file._getmaxstdio()
if maxstdio < limit:
logging.debug("Current maxstdio: %s, changing to %s..." % (maxstdio, limit))
win32file._setmaxstdio(limit)
return True
else:
import resource
soft, hard = resource.getrlimit(resource.RLIMIT_NOFILE)
if soft < limit:
logging.debug("Current RLIMIT_NOFILE: %s, changing to %s..." % (soft, limit))
resource.setrlimit(resource.RLIMIT_NOFILE, (soft, hard))
return True
except Exception, err:
logging.error("Failed to modify max files open limit: %s" % err)
return False