mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-05-04 00:01:30 -07:00
Use a consistent RLIMIT_NOFILE for ansible-test.
This commit is contained in:
parent
d99728d9e6
commit
e8a31a12be
5 changed files with 38 additions and 12 deletions
|
@ -4,9 +4,14 @@ from __future__ import absolute_import, print_function
|
|||
|
||||
import errno
|
||||
import os
|
||||
import resource
|
||||
import sys
|
||||
|
||||
# This import should occur as early as possible.
|
||||
# It must occur before subprocess has been imported anywhere in the current process.
|
||||
from lib.init import (
|
||||
CURRENT_RLIMIT_NOFILE,
|
||||
)
|
||||
|
||||
from lib.util import (
|
||||
ApplicationError,
|
||||
display,
|
||||
|
@ -14,6 +19,7 @@ from lib.util import (
|
|||
get_docker_completion,
|
||||
generate_pip_command,
|
||||
read_lines_without_comments,
|
||||
MAXFD,
|
||||
)
|
||||
|
||||
from lib.delegation import (
|
||||
|
@ -90,16 +96,8 @@ def main():
|
|||
display.info_stderr = (isinstance(config, SanityConfig) and config.lint) or (isinstance(config, IntegrationConfig) and config.list_targets)
|
||||
check_startup()
|
||||
|
||||
# to achieve a consistent nofile ulimit, set to 16k here, this can affect performance in subprocess.Popen when
|
||||
# being called with close_fds=True on Python (8x the time on some environments)
|
||||
nofile_limit = 16 * 1024
|
||||
current_limit = resource.getrlimit(resource.RLIMIT_NOFILE)
|
||||
new_limit = (nofile_limit, nofile_limit)
|
||||
if current_limit > new_limit:
|
||||
display.info('RLIMIT_NOFILE: %s -> %s' % (current_limit, new_limit), verbosity=2)
|
||||
resource.setrlimit(resource.RLIMIT_NOFILE, (nofile_limit, nofile_limit))
|
||||
else:
|
||||
display.info('RLIMIT_NOFILE: %s' % (current_limit, ), verbosity=2)
|
||||
display.info('RLIMIT_NOFILE: %s' % (CURRENT_RLIMIT_NOFILE,), verbosity=2)
|
||||
display.info('MAXFD: %d' % MAXFD, verbosity=2)
|
||||
|
||||
try:
|
||||
args.func(config)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue