-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ModuleNotFoundError with multiprocessing and import-mode=importlib #12178
Comments
Also, the failure doesn't occur if the tests are invoked with |
…sion 25.1.0 Jason R. Coombs (11): Re-enable ignoring of temporary merge queue branches. Closes jaraco/skeleton#103. Fetch unshallow clones in readthedocs. Closes jaraco/skeleton#114. Move Python 3.11 out of the test matrix. Configure pytest to support namespace packages. Ref pytest-dev/pytest#12112. Replace ExceptionRaisedContext with ExceptionTrap. Remove test skip, no longer relevant with Python 3.8 minimum. Inject the current directory to sys.path in multiprocessing tests. Closes #673. Ref pytest-dev/pytest#12178. Move Python 3.8 compatibility logic into the compat package. When completion is unavailable, exit with non-zero status and emit message to stderr. Finalize Finalize
AH! I have this same issue! I couldn't figure out what I was doing wrong, but now I know it's the mode that is the problem. I checked by running my tests that use multiprocessing (that had been having those errors) via |
It seems this has been the case for a while, since #10965 at least. Comments there indicate that multiprocessing might just be incompatible with the importlib import mode ... ? I'm not well-versed enough to know if that's true or not, but if that IS the case, since that mode is recommended by the documentation, perhaps it's worth a specific callout in the docs that it won't work with multiprocessing? |
Duplicate of #10965 |
In jaraco/keyring#673, I captured an issue stemming from the introduction of
--import-mode importlib
to jaraco/skeleton projects. In jaraco/keyring@6ff02e0, I'm attempting to enable importlib mode for all projects in order to support projects that use namespaces and those that don't in a uniform way. However, enabling importlib mode causes failures in tests that involve multiprocessing. Consider this minimal example:The same error occurs even if
tests/__init__.py
is present. The issue occurs also with pytest 8.0.2 and 7.4.4. My guess is that it never worked with this mode.It seems that
tests.test_multiprocess
is insys.modules
and objects passed between the processes might reference that module, so the child process needs to have the same path handling that the parent had but doesn't.Running
tox -- --import-mode prepend
ortox -- --import-mode append
bypasses the failure.Can multiprocessing be made to work with import-mode importlib?
The text was updated successfully, but these errors were encountered: