mirror of
https://github.com/internetarchive/warcprox.git
synced 2025-01-18 13:22:09 +01:00
handle case of unlimited resource limits and cap max_threads at 5000
This commit is contained in:
parent
fa1e8d3af4
commit
1671080755
2
setup.py
2
setup.py
@ -51,7 +51,7 @@ except:
|
||||
|
||||
setuptools.setup(
|
||||
name='warcprox',
|
||||
version='2.0b2.dev33',
|
||||
version='2.0b2.dev34',
|
||||
description='WARC writing MITM HTTP/S proxy',
|
||||
url='https://github.com/internetarchive/warcprox',
|
||||
author='Noah Levitt',
|
||||
|
@ -417,6 +417,9 @@ class PooledMixIn(socketserver.ThreadingMixIn):
|
||||
rlimit_nproc = resource.getrlimit(resource.RLIMIT_NPROC)[0]
|
||||
rlimit_nofile = resource.getrlimit(resource.RLIMIT_NOFILE)[0]
|
||||
max_threads = min(rlimit_nofile // 10, rlimit_nproc // 2)
|
||||
# resource.RLIM_INFINITY == -1 which can result in max_threads == 0
|
||||
if max_threads <= 0 or max_threads > 5000:
|
||||
max_threads = 5000
|
||||
self.logger.info(
|
||||
"max_threads=%s (rlimit_nproc=%s, rlimit_nofile=%s)",
|
||||
max_threads, rlimit_nproc, rlimit_nofile)
|
||||
|
Loading…
x
Reference in New Issue
Block a user