Skip to content

vscode_pytest with mpi deadlock #25663

Open

Description

@mattfil

Type: Bug

I am trying to use the package https://github.com/dlr-sp/pytest-isolate-mpi. I have installed:

  • conda install conda-forge::openmpi
  • conda install conda-forge::mpi4py
  • pip install pytest-isolate-mpi

This is the code I am playing with:

import pytest

@pytest.mark.mpi(ranks=1)
def test_with_mpi(mpi_ranks) -> None:
    assert True

If I run the test from the vscode gui buttons (pytest is called with -p vscode_pytest) the test never finish (like if there is a deadlock in mpi). If instead I run from terminal, or if in conftest.py or in settings.json I disable vscode_pytest (e.g. with -p no:vscode_pytest), the test runs and is ok, but the markers on the testing panel are no more updated (i.e. the test is shown as failed).
This is what i get when I disable vscode_pytest:
Image
So this behaviour seems to be related to the interaction between vscode_pytest and mpi4py.
If it is not a bug from vscode side, feel free to close the issue.

VS Code version: Code 1.101.2 (2901c5ac6db8a986a5666c3af51ff804d05af0d4, 2025-06-24T20:27:15.391Z)
OS version: Windows_NT x64 10.0.26100
Modes:
Remote OS version: Linux x64 6.6.87.2-microsoft-standard-WSL2

System Info
Item Value
CPUs 11th Gen Intel(R) Core(TM) i7-11370H @ 3.30GHz (8 x 3302)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) undefined
Memory (System) 15.79GB (2.61GB free)
Process Argv --folder-uri=vscode-remote://wsl+Ubuntu/home/mattia/pytwinfabrica --remote=wsl+Ubuntu --crash-reporter-id e4b4f9bf-03bd-4f43-8f88-fcac878f7f83
Screen Reader no
VM 50%
Item Value
Remote WSL: Ubuntu
OS Linux x64 6.6.87.2-microsoft-standard-WSL2
CPUs 11th Gen Intel(R) Core(TM) i7-11370H @ 3.30GHz (8 x 0)
Memory (System) 13.33GB (9.90GB free)
VM 0%
Extensions (22)
Extension Author (truncated) Version
jupyter-keymap ms- 1.1.2
remote-containers ms- 0.417.0
remote-ssh ms- 0.120.0
remote-ssh-edit ms- 0.87.0
remote-wsl ms- 0.99.0
vscode-remote-extensionpack ms- 0.26.0
remote-explorer ms- 0.5.0
remote-server ms- 1.5.2
ruff cha 2025.24.0
gitlens eam 17.3.0
debugpy ms- 2025.8.0
mypy-type-checker ms- 2025.2.0
python ms- 2025.8.1
vscode-pylance ms- 2025.6.2
jupyter ms- 2025.6.0
jupyter-keymap ms- 1.1.2
jupyter-renderers ms- 1.3.0
vscode-jupyter-cell-tags ms- 0.1.9
vscode-jupyter-slideshow ms- 0.1.6
live-server ms- 0.4.15
autodocstring njp 0.6.1
vscode-coverage-gutters rya 2.13.0
A/B Experiments
vsliv368:30146709
vspor879:30202332
vspor708:30202333
vspor363:30204092
binariesv615:30325510
c4g48928:30535728
azure-dev_surveyone:30548225
962ge761:30959799
h48ei257:31000450
cppperfnew:31000557
dwnewjupytercf:31046870
nativeloc1:31344060
5fd0e150:31155592
dwcopilot:31170013
6074i472:31201624
dwoutputs:31242946
customenabled:31248079
hdaa2157:31222309
copilot_t_ci:31333650
e5gg6876:31282496
pythoneinst12:31285622
4gafe986:31271826
c7cif404:31314491
pythonpulldiag:31343502
996jf627:31283433
pythonrdcb7:31342333
usemplatestapi:31297334
0aa6g176:31307128
7bj51361:31289155
747dc170:31275177
aj953862:31281341
generatesymbolt:31295002
convertfstringf:31295003
pylancequickfixt:31329274
9d2cg352:31339597
jhi8h917:31341130
d7aab740:31338110
usemarketplace:31343026
nesew2to5:31336538
agentclaude:31335815
mytest:31335657
4f60g487:31327383
nes-diff-11:31337487
testaa123cf:31335227
onetestforazureexp:31335613
63221493:31336333
yijiwantestdri0626-c:31336931
4gdec884:31342391

Activity

  1. mattfil commented on Jul 11, 2025

    @mattfil
    Author

    In debug mode, I was able to get the error traceback, which indeed is related to mpi4py not finding vscode_pytest plugin.

    Running pytest with args: ['-p', 'vscode_pytest', '-vv', '--showlocals', '--tb=short', '--rootdir=/home/mattia/pytwinfabrica', '/home/mattia/pytwinfabrica/tests/dummy/dummy_test.py::test_with_mpi[1]']
    ============================= test session starts ==============================
    platform linux -- Python 3.13.2, pytest-8.4.1, pluggy-1.6.0 -- /home/mattia/miniconda3/envs/newenv/bin/python
    cachedir: .pytest_cache
    rootdir: /home/mattia/pytwinfabrica
    configfile: pyproject.toml
    plugins: xdist-3.8.0, reportlog-0.4.0, mpi-pytest-2025.7.0.dev0, isolate-mpi-0.3
    collecting ... collected 1 item
    
    tests/dummy/dummy_test.py::test_with_mpi[1] FAILED                       [100%]
    
    =================================== FAILURES ===================================
    _______________________________ test_with_mpi[1] _______________________________
    At least one MPI process has exited prematurely.
    ------------------------------- Captured stdout --------------------------------
    
    ------------------------------- Captured stderr --------------------------------
    Traceback (most recent call last):
      File "/home/mattia/miniconda3/envs/newenv/lib/python3.13/site-packages/_pytest/config/__init__.py", line 860, in import_plugin
        __import__(importspec)
        ~~~~~~~~~~^^^^^^^^^^^^
    ModuleNotFoundError: No module named 'vscode_pytest'
    
    The above exception was the direct cause of the following exception:
    
    Traceback (most recent call last):
      File "<frozen runpy>", line 198, in _run_module_as_main
      File "<frozen runpy>", line 88, in _run_code
      File "/home/mattia/miniconda3/envs/newenv/lib/python3.13/site-packages/mpi4py/__main__.py", line 8, in <module>
        main()
        ~~~~^^
      File "/home/mattia/miniconda3/envs/newenv/lib/python3.13/site-packages/mpi4py/run.py", line 320, in main
        run_command_line(args)
        ~~~~~~~~~~~~~~~~^^^^^^
      File "/home/mattia/miniconda3/envs/newenv/lib/python3.13/site-packages/mpi4py/run.py", line 48, in run_command_line
        run_module(sys.argv[0], run_name="__main__", alter_sys=True)
        ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "<frozen runpy>", line 226, in run_module
      File "<frozen runpy>", line 98, in _run_module_code
      File "<frozen runpy>", line 88, in _run_code
      File "/home/mattia/miniconda3/envs/newenv/lib/python3.13/site-packages/pytest/__main__.py", line 9, in <module>
        raise SystemExit(pytest.console_main())
                         ~~~~~~~~~~~~~~~~~~~^^
      File "/home/mattia/miniconda3/envs/newenv/lib/python3.13/site-packages/_pytest/config/__init__.py", line 201, in console_main
        code = main()
      File "/home/mattia/miniconda3/envs/newenv/lib/python3.13/site-packages/_pytest/config/__init__.py", line 156, in main
        config = _prepareconfig(args, plugins)
      File "/home/mattia/miniconda3/envs/newenv/lib/python3.13/site-packages/_pytest/config/__init__.py", line 342, in _prepareconfig
        config = pluginmanager.hook.pytest_cmdline_parse(
            pluginmanager=pluginmanager, args=args
        )
      File "/home/mattia/miniconda3/envs/newenv/lib/python3.13/site-packages/pluggy/_hooks.py", line 512, in __call__
        return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
               ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/mattia/miniconda3/envs/newenv/lib/python3.13/site-packages/pluggy/_manager.py", line 120, in _hookexec
        return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
               ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/mattia/miniconda3/envs/newenv/lib/python3.13/site-packages/pluggy/_callers.py", line 167, in _multicall
        raise exception
      File "/home/mattia/miniconda3/envs/newenv/lib/python3.13/site-packages/pluggy/_callers.py", line 139, in _multicall
        teardown.throw(exception)
        ~~~~~~~~~~~~~~^^^^^^^^^^^
      File "/home/mattia/miniconda3/envs/newenv/lib/python3.13/site-packages/_pytest/helpconfig.py", line 112, in pytest_cmdline_parse
        config = yield
                 ^^^^^
      File "/home/mattia/miniconda3/envs/newenv/lib/python3.13/site-packages/pluggy/_callers.py", line 121, in _multicall
        res = hook_impl.function(*args)
      File "/home/mattia/miniconda3/envs/newenv/lib/python3.13/site-packages/_pytest/config/__init__.py", line 1146, in pytest_cmdline_parse
        self.parse(args)
        ~~~~~~~~~~^^^^^^
      File "/home/mattia/miniconda3/envs/newenv/lib/python3.13/site-packages/_pytest/config/__init__.py", line 1527, in parse
        self._preparse(args, addopts=addopts)
        ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/mattia/miniconda3/envs/newenv/lib/python3.13/site-packages/_pytest/config/__init__.py", line 1405, in _preparse
        self.pluginmanager.consider_preparse(args, exclude_only=False)
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/mattia/miniconda3/envs/newenv/lib/python3.13/site-packages/_pytest/config/__init__.py", line 789, in consider_preparse
        self.consider_pluginarg(parg)
        ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
      File "/home/mattia/miniconda3/envs/newenv/lib/python3.13/site-packages/_pytest/config/__init__.py", line 812, in consider_pluginarg
        self.import_plugin(arg, consider_entry_points=True)
        ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/mattia/miniconda3/envs/newenv/lib/python3.13/site-packages/_pytest/config/__init__.py", line 862, in import_plugin
        raise ImportError(
            f'Error importing plugin "{modname}": {e.args[0]}'
        ).with_traceback(e.__traceback__) from e
      File "/home/mattia/miniconda3/envs/newenv/lib/python3.13/site-packages/_pytest/config/__init__.py", line 860, in import_plugin
        __import__(importspec)
        ~~~~~~~~~~^^^^^^^^^^^^
    ImportError: Error importing plugin "vscode_pytest": No module named 'vscode_pytest'
    =========================== short test summary info ============================
    FAILED tests/dummy/dummy_test.py::test_with_mpi[1]
    ============================== 1 failed in 0.28s ===============================
    
  2. eleanorjboyd commented on Dec 9, 2025

    @eleanorjboyd
    Member

    after you try and run the tests can you include the logs from the python extension output log

  3. eleanorjboyd commented on Dec 17, 2025

    @eleanorjboyd
    Member

    I think this will be a feature request to support it with mpi... going to mark as such for now

  4. github-actions commented on Dec 17, 2025

    @github-actions

    Thanks for the feature request! We are going to give the community 60 days from when this issue was created to provide 7 👍 upvotes on the opening comment to gauge general interest in this idea. If there's enough upvotes then we will consider this feature request in our future planning. If there's unfortunately not enough upvotes then we will close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions