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.
()
| 553 | |
| 554 | |
| 555 | def 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 | |
| 581 | def get_host_runner() -> str: |
no test coverage detected