MCPcopy Index your code
hub / github.com/RustPython/RustPython / adjust_rlimit_nofile

Function adjust_rlimit_nofile

Lib/test/libregrtest/utils.py:555–578  ·  view source on GitHub ↗

On macOS the default fd limit (RLIMIT_NOFILE) is sometimes too low (256) for our test suite to succeed. Raise it to something more reasonable. 1024 is a common Linux default.

()

Source from the content-addressed store, hash-verified

553
554
555def adjust_rlimit_nofile() -> None:
556 """
557 On macOS the default fd limit (RLIMIT_NOFILE) is sometimes too low (256)
558 for our test suite to succeed. Raise it to something more reasonable. 1024
559 is a common Linux default.
560 """
561 try:
562 import resource
563 except ImportError:
564 return
565
566 fd_limit, max_fds = resource.getrlimit(resource.RLIMIT_NOFILE)
567
568 desired_fds = 1024
569
570 if fd_limit < desired_fds and fd_limit < max_fds:
571 new_fd_limit = min(desired_fds, max_fds)
572 try:
573 resource.setrlimit(resource.RLIMIT_NOFILE,
574 (new_fd_limit, max_fds))
575 print(f"Raised RLIMIT_NOFILE: {fd_limit} -> {new_fd_limit}")
576 except (ValueError, OSError) as err:
577 print_warning(f"Unable to raise RLIMIT_NOFILE from {fd_limit} to "
578 f"{new_fd_limit}: {err}.")
579
580
581def get_host_runner() -> str:

Callers 1

setup_processFunction · 0.85

Calls 3

minFunction · 0.85
print_warningFunction · 0.70
printFunction · 0.50

Tested by

no test coverage detected