hermes - ✅(Solved) Fix [Bug]: pytest -n auto can fail with EMFILE (Too many open files) on low-FD macOS [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
NousResearch/hermes-agent#11645Fetched 2026-04-18 05:59:36
View on GitHub
Comments
0
Participants
1
Timeline
1
Reactions
0
Author
Participants
Timeline (top)
cross-referenced ×1

Error Message

OSError: [Errno 24] Too many open files

Root Cause

Root Cause Analysis (optional)

Strongly suggested cause: default pytest config uses xdist auto workers (pyproject.toml has addopts = "-m 'not integration' -n auto").

Fix Action

Fixed

PR fix notes

PR #11672: fix(tests): stop forcing xdist auto by default

Description (problem / solution / changelog)

What does this PR do?

Fixes the default local pytest entrypoint so it no longer forces -n auto from pyproject.toml.

Issue #11645 reports EMFILE crashes on low-FD macOS hosts when developers run the repo's default non-integration pytest command. The root cause is that pyproject.toml still hardcodes -n auto, while the repo already documents scripts/run_tests.sh as the canonical CI-like runner and that script pins a bounded worker count.

This PR removes -n auto from the default pytest addopts, keeps the existing not integration filter, updates CONTRIBUTING to point contributors at scripts/run_tests.sh, and adds a regression test so -n auto does not silently creep back into the default config.

Related Issue

Fixes #11645

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

  • change pyproject.toml pytest addopts from -m 'not integration' -n auto to -m 'not integration'
  • update CONTRIBUTING.md so the documented full-suite command is scripts/run_tests.sh
  • add a metadata regression test asserting default pytest addopts do not force -n auto

How to Test

  1. ./.venv/bin/python -m pytest tests/test_project_metadata.py -q
  2. Confirm the new regression test passes and pyproject.toml default addopts are -m 'not integration'
  3. Run scripts/run_tests.sh when you want the bounded CI-like parallel path

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: macOS local metadata regression test in repo .venv

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

Screenshots / Logs

  • ./.venv/bin/python -m pytest tests/test_project_metadata.py -q
  • 3 passed in 0.10s

Changed files

  • CONTRIBUTING.md (modified, +6/-2)
  • pyproject.toml (modified, +1/-1)
  • tests/test_project_metadata.py (modified, +23/-1)

Code Example

uv venv .venv --python 3.11
   source .venv/bin/activate
   uv pip install -e ".[all,dev]"

---

ulimit -n
   # 256

---

python -m pytest tests/ -q --ignore=tests/integration --ignore=tests/e2e --tb=short -n auto

---

OSError: [Errno 24] Too many open files

---

19 failed, 11905 passed, 38 skipped, 157 warnings, 632 errors

---

Exception ignored in sys.unraisablehook ...
OSError: [Errno 24] Too many open files
RAW_BUFFERClick to expand / collapse

Bug Description

Running the default non-integration pytest command with xdist auto-workers on macOS with a low open-file limit (ulimit -n = 256) can crash with OSError: [Errno 24] Too many open files.

This appears to be test-runner resource exhaustion, not product behavior.

Steps to Reproduce

  1. Clone the repo and install dev deps:
    uv venv .venv --python 3.11
    source .venv/bin/activate
    uv pip install -e ".[all,dev]"
  2. Confirm low fd limit:
    ulimit -n
    # 256
  3. Run:
    python -m pytest tests/ -q --ignore=tests/integration --ignore=tests/e2e --tb=short -n auto

Expected Behavior

The default test command should complete reliably on supported local dev environments, or degrade gracefully (e.g., fewer workers) instead of exhausting file descriptors.

Actual Behavior

The run eventually throws repeated:

OSError: [Errno 24] Too many open files

Observed summary from one run:

19 failed, 11905 passed, 38 skipped, 157 warnings, 632 errors

Targeted serial runs pass (e.g., -n 0 on tests/test_hermes_state.py, tests/test_mcp_serve.py, tests/tools/test_voice_mode.py).

Affected Component

  • Other

(Practically: local test execution defaults / pytest config)

Messaging Platform (if gateway-related)

  • N/A (CLI only)

Debug Report

N/A for this report (repo-level test runner behavior).

Operating System

macOS (arm64)

Python Version

3.11.15

Hermes Version

0.10.0

Additional Logs / Traceback (optional)

Representative error snippet:

Exception ignored in sys.unraisablehook ...
OSError: [Errno 24] Too many open files

Root Cause Analysis (optional)

Strongly suggested cause: default pytest config uses xdist auto workers (pyproject.toml has addopts = "-m 'not integration' -n auto").

On hosts with low ulimit -n, worker/process/socket/db descriptor usage appears to exceed available FDs during broad test runs.

Proposed Fix (optional)

Any of these would likely harden local runs:

  1. Remove unconditional -n auto from default addopts; keep parallelism in CI command only.
  2. Dynamically cap worker count based on available ulimit -n.
  3. Document a safe local fallback (-n 0 or small -n) in CONTRIBUTING.
  4. Add a preflight warning when ulimit -n is too low for auto-parallel full-suite runs.

Are you willing to submit a PR for this?

  • I'd like to fix this myself and submit a PR

extent analysis

TL;DR

To fix the issue, consider removing the unconditional -n auto from the default addopts in pyproject.toml to prevent excessive file descriptor usage during parallel test runs.

Guidance

  • Review the pyproject.toml file and consider modifying the addopts to remove -n auto for local test runs, reserving parallelism for CI environments.
  • Before running tests, check the ulimit -n value to ensure it's sufficient for the test suite; a low value may require adjusting the test configuration or using a smaller -n value.
  • Implementing a dynamic cap on worker count based on available file descriptors could provide a more robust solution, but this may require additional development effort.
  • Documenting a safe local fallback, such as using -n 0 or a small -n value, in the project's CONTRIBUTING guide can help other developers avoid this issue.

Example

No code snippet is provided as the issue is more related to configuration and test runner settings rather than specific code changes.

Notes

The proposed fixes aim to mitigate the issue by adjusting the test runner configuration rather than modifying the code itself. The effectiveness of these solutions may depend on the specific requirements and constraints of the project.

Recommendation

Apply a workaround by removing the unconditional -n auto from the default addopts or documenting a safe local fallback, as this is a more straightforward and immediate solution to prevent test runner resource exhaustion.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

hermes - ✅(Solved) Fix [Bug]: pytest -n auto can fail with EMFILE (Too many open files) on low-FD macOS [1 pull requests, 1 participants]