forked from HelloZeroNet/ZeroNet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rev948, Disable websocket logging, Change max files opened limit on s…
…tartup
- Loading branch information
1 parent
dba42f5
commit 2a06cec
Showing
4 changed files
with
36 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |