From 9a471aff1bb9dfe59438056790882f3ca9183ad7 Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Thu, 9 Jun 2022 22:14:12 +0200 Subject: [PATCH] WebHost: request maximum amount of file handles from the system for autolauncher. (#625) * WebHost: request maximum amount of file handles from the system for autolauncher. * WebHostLib: wrap resource import into try to restore windows compatibility --- WebHostLib/autolauncher.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/WebHostLib/autolauncher.py b/WebHostLib/autolauncher.py index 522bbdd1..9d7b7f49 100644 --- a/WebHostLib/autolauncher.py +++ b/WebHostLib/autolauncher.py @@ -210,6 +210,16 @@ def run_guardian(): global multiworlds with guardian_lock: if not guardian: + try: + import resource + except ModuleNotFoundError: + pass # unix only module + else: + # Each Server is another file handle, so request as many as we can from the system + file_limit = resource.getrlimit(resource.RLIMIT_NOFILE)[1] + # set soft limit to hard limit + resource.setrlimit(resource.RLIMIT_NOFILE, (file_limit, file_limit)) + def guard(): while 1: time.sleep(1)