Don't change already suspended threads in subsequent suspend calls
Previously, already-suspended threads could still be modified by subsequent calls to suspend_all_threads. This change adds checks to prevent this.
This doesn't seem correct (which is probably why tests are failing).
I guess I also don't understand the real issue behind the need for this change.
We've encountered some issues where upon reaching a breakpoint location, pydevd will try to suspend all other threads. But at this point, another thread might race and reach this codepath as well and try to suspend all threads as well, before the suspended state notification is fired. This can cause pydevd not to emit a thread suspend notification (i.e. to debugpy and thus to VS Code), so the debugger UI never refreshes even though breakpoints where hit.
I'm trying to figure out the tests before I publish this. They all seem related to django?
Thought I had a fix but didn't. Will revisit this later
@fabioz Any advice running the tests_python locally? I followed a similar setup to the GitHub actions workflow on a Linux host but am running into timeout errors in pytest.