Skip to content

gh-155912: Handle PermissionError from os.sysconf under sandbox - #155955

Closed
imabd645 wants to merge 4 commits into
python:mainfrom
imabd645:fix-processpool-sandbox-155912
Closed

gh-155912: Handle PermissionError from os.sysconf under sandbox#155955
imabd645 wants to merge 4 commits into
python:mainfrom
imabd645:fix-processpool-sandbox-155912

Conversation

@imabd645

@imabd645 imabd645 commented Aug 17, 2026

Copy link
Copy Markdown

Description

This PR fixes a bug where concurrent.futures.ProcessPoolExecutor fails to construct on macOS (and other environments) when run under a strict sandbox profile that denies sysctl reads.

When the sandbox denies access, os.sysconf("SC_SEM_NSEMS_MAX") raises a PermissionError (a subclass of OSError). Previously, _check_system_limits() only caught AttributeError and ValueError, meaning the PermissionError propagated up and fatally broke the executor initialization, even though the underlying semaphore primitives were fully functional.

Changes:

  • Added OSError to the caught exceptions in _check_system_limits() in Lib/concurrent/futures/process.py, allowing the executor to gracefully fall back to assuming an undetermined limit when read access is denied.
  • Added a regression test in Lib/test/test_concurrent_futures/test_process_pool.py that mocks os.sysconf to simulate a strict sandbox and asserts that the ProcessPoolExecutor initializes successfully.

@bedevere-app

bedevere-app Bot commented Aug 17, 2026

Copy link
Copy Markdown

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@picnixz

picnixz commented Aug 17, 2026

Copy link
Copy Markdown
Member

The issue's OP suggested to open a PR themselves, please ask them first if they want to still do it.

@picnixz picnixz closed this Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants