issue #362: cap max open files in children.

issue72
David Wilson 6 years ago
parent 86ff2cc768
commit f8b6c774dd

@ -43,6 +43,7 @@ import operator
import os
import pwd
import re
import resource
import signal
import stat
import subprocess
@ -90,6 +91,15 @@ _fork_parent = None
good_temp_dir = None
# subprocess.Popen(close_fds=True) aka. AnsibleModule.run_command() loops the
# entire SC_OPEN_MAX space. CentOS>5 ships with 1,048,576 FDs by default,
# resulting in huge (>500ms) runtime waste running many commands. Therefore if
# we are a child context, cap the insane FD count to something reasonable.
if subprocess.MAXFD > 512 and not mitogen.is_master:
subprocess.MAXFD = 512
resource.setrlimit(resource.RLIMIT_NOFILE, (512, 512))
def get_small_file(context, path):
"""
Basic in-memory caching module fetcher. This generates an one roundtrip for

Loading…
Cancel
Save