From 450f6b80d0b7da2ea1bf29ead66abc8399169d7e Mon Sep 17 00:00:00 2001 From: Chris <137902980+wandercone@users.noreply.github.com> Date: Sun, 28 Jun 2026 20:42:26 -0500 Subject: [PATCH] fix: address ulimit exhaustion of user Proxies table briefly loads then disappears on full page load. This will dynamically assign max_workers based on resource.RLIMIT_NPROC Signed-off-by: Chris <137902980+wandercone@users.noreply.github.com> --- root/dashboard/swag-proxies.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/root/dashboard/swag-proxies.py b/root/dashboard/swag-proxies.py index a0c916f1b..69072d35c 100644 --- a/root/dashboard/swag-proxies.py +++ b/root/dashboard/swag-proxies.py @@ -4,6 +4,7 @@ import json import os import re +import resource import socket import sys import urllib3 @@ -69,12 +70,21 @@ def is_available(url): finally: s.close() +def get_max_workers(default=50, reserve=10): + try: + max_procs, _ = resource.getrlimit(resource.RLIMIT_NPROC) + if max_procs == resource.RLIM_INFINITY: + return default + return max(1, min(default, max_procs - reserve)) + except (AttributeError, ValueError, OSError): + return default + urllib3.disable_warnings() fast = (len(sys.argv) > 1) apps, auths = find_apps(fast) discovered_apps = collections.defaultdict(dict) -with concurrent.futures.ThreadPoolExecutor(max_workers=100) as executor: +with concurrent.futures.ThreadPoolExecutor(max_workers=get_max_workers()) as executor: futures = {executor.submit(is_available, app): app for app in apps.keys()} for future in concurrent.futures.as_completed(futures): app = futures[future]