[Python] How to forcefully terminate a running Python test in VSCode

Discussão em 'Python' iniciado por Stack, Julho 11, 2025.

  1. Stack

    Stack Membro Participativo

    Closely related to my question is VSCode: how to interrupt a running Python test?, however in my case the standard method of pressing the square in the Test Results tap does not work.

    What is different in my tests?

    I have code that via multiprocessing (and os.fork) executes multiple sub processes. There are two issues that cause the tests to be stuck. One, because of the forking (involving JAX) a deadlock happens when several tests are executed in one set, this seems to be a limitation of unittest cleanup.
    Secondly, I sometimes forget to remove breakpoint from code that is executed in these other processes. Additionally is a custom debugger in place of the standard pdb that would allow debugging and hooking into these processes when executed normally - but not when using tests. To be precise I am using ray's distributed debugger and the last message I get is that the debugger is now active. This prevents the tests from being stopped in the normal way via the square button.

    I tried to kill some python processes found by ps aux | grep python but there is a long list of results, I don't know which is the correct to select. The only sure way I have is to reload the whole VSCode window.

    Is there another integrated method that allows to immediately terminate a running test that will work in my case?

    Continue reading...

Compartilhe esta Página