fix(state): tolerate Windows resource stubs
This commit is contained in:
@@ -101,7 +101,7 @@ def _fd_soft_limit() -> Optional[int]:
|
||||
return None
|
||||
try:
|
||||
soft, _hard = resource.getrlimit(resource.RLIMIT_NOFILE)
|
||||
except (OSError, ValueError):
|
||||
except (AttributeError, OSError, ValueError):
|
||||
return None
|
||||
if soft in (resource.RLIM_INFINITY, -1):
|
||||
return None
|
||||
|
||||
@@ -100,6 +100,13 @@ def test_unsupported_platform_is_a_safe_noop(monkeypatch):
|
||||
assert resource_limits.apply_nofile_soft_limit({}) is False
|
||||
|
||||
|
||||
def test_windows_resource_stub_without_rlimit_attributes_is_a_safe_noop(monkeypatch):
|
||||
"""Windows can import ``resource`` even when its POSIX API is absent."""
|
||||
monkeypatch.setattr(resource_limits, "_resource", object())
|
||||
|
||||
assert resource_limits.apply_nofile_soft_limit({}) is False
|
||||
|
||||
|
||||
def test_fresh_process_import_without_posix_resource_is_a_safe_noop():
|
||||
code = textwrap.dedent(
|
||||
"""
|
||||
|
||||
@@ -627,6 +627,16 @@ def test_fd_headroom_guard_fails_open_where_it_cannot_measure(monkeypatch):
|
||||
assert readpool._fd_headroom_ok() is False
|
||||
|
||||
|
||||
def test_fd_soft_limit_ignores_windows_resource_stub(monkeypatch):
|
||||
"""A Windows resource stub has no POSIX RLIMIT attributes."""
|
||||
import sys
|
||||
from types import SimpleNamespace
|
||||
|
||||
monkeypatch.setitem(sys.modules, "resource", SimpleNamespace())
|
||||
|
||||
assert hermes_state_readpool._fd_soft_limit() is None
|
||||
|
||||
|
||||
@pytest.mark.requires_wal
|
||||
def test_duplicate_handles_on_one_path_are_reported(db, caplog):
|
||||
"""Writer connections cannot be capped, so duplicates must be visible."""
|
||||
|
||||
Reference in New Issue
Block a user