Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Fix errors with multiprocessing#521

Merged
jaraco merged 11 commits into
python:mainpython/importlib_metadata:mainfrom
2xB:fix5202xB/importlib_metadata:fix520Copy head branch name to clipboard
Dec 21, 2025
Merged

Fix errors with multiprocessing#521
jaraco merged 11 commits into
python:mainpython/importlib_metadata:mainfrom
2xB:fix5202xB/importlib_metadata:fix520Copy head branch name to clipboard

Conversation

@2xB

@2xB 2xB commented Jun 8, 2025

Copy link
Copy Markdown
Contributor

Before, one could get OSError 22 and BadZipFile errors due to re-used file pointers in forked subprocesses.

This implements the fix recommended by @anntzer .

Fixes #520

@jaraco jaraco left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I especially like that the behavior is essentially a no-op except in the affected scenario.

I don't love that the code is detached from its locus of effect, and while the comments help, I'd prefer if we could model the effect in Python syntax, such as a decorator around functools.lru_cache(new) that performs the registration. That decorator could also have a docstring capturing the narrative currently in comments.

The other thing that would be nice to have is a regression test (a test that would replicate the failure with the workaround removed). It might be a little tricky, as the repro steps described in the issue were intermittent, but if it's possible, we should add one that guarantees that multiprocessing usage works in the supported scenarios. Let's try to put together a test to capture the failure. That test should fail on main and pass in this PR.

@2xB

2xB commented Nov 26, 2025

Copy link
Copy Markdown
Contributor Author

@jaraco Good success catching up on Pull Requests! Do I understand correctly that you are working with Copilot on the requested changes?

@jaraco

jaraco commented Dec 20, 2025

Copy link
Copy Markdown
Member

@jaraco Good success catching up on Pull Requests! Do I understand correctly that you are working with Copilot on the requested changes?

I was hoping to simply assign to Copilot and it would work on it, but it seems that's not the case. I have had success using GitHub Copilot in VS Code and pointing it at issues, so I'll see what it that can achieve (even though it's more manually intensive).

@jaraco jaraco merged commit 36ed6f6 into python:main Dec 21, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Issues when combined with multiprocessing (MaybeEncodingError, BadZipFile, OSError)

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.