Skip to content
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

Stepping in a multithreaded application jumps to other threads #1765

Closed
rchiodo opened this issue Dec 11, 2024 · 9 comments
Closed

Stepping in a multithreaded application jumps to other threads #1765

rchiodo opened this issue Dec 11, 2024 · 9 comments
Assignees
Labels
Fixed in next release This issue has been fixed, but won't be available to customers until the next release.

Comments

@rchiodo
Copy link
Contributor

rchiodo commented Dec 11, 2024

Discussed in #1761

Originally posted by pub-pub December 10, 2024
i posted my initial issue here and it was successfully resolved.

now i'm using "steppingResumesAllThreads": false setting for debugging. but this solutions has a drawback, it pauses all other threads.

is it possible to add one more setting that will keep debugger Stepping inside my initial thread without pausing all other threads?

@github-actions github-actions bot added the needs repro Issue has not been reproduced yet label Dec 11, 2024
@rchiodo
Copy link
Contributor Author

rchiodo commented Dec 11, 2024

Here's some source code to reproduce the problem:

import threading
import time
import requests

def request_get(url):
    # return "abc"
    with requests.get(url) as data:
        return data.text

def watcher():
    while True:
        print(1)
        time.sleep(3)

def worker ():
    while True:
        print(len(request_get("https://dns.google//")))
        time.sleep(5)

threading.Thread(daemon=True, target=watcher).start()
t1 = threading.Thread(target=worker)
t1.start()
t2 = threading.Thread(target=worker)
t2.start()
t1.join()
t2.join()

Set a breakpoint on line 11 (the print(1)) in the watcher and step. It will eventually end up in the other thread

@xmatthias
Copy link

I'm encountering the same - though in a pretty large codebase where so far i didn't take the time to create a reproduction.

It's not just "on step" for me, either - also the initial breakpoint may stop - shows you that code for a second - and then (as other threads stop) it'll jump to other parts of the code (other files, running in other threads), pulling me away from the code i wanted to look at / debug, having me go back to the original.
it's happening on step too - but it's not limited to "step" as far as i did experience.

it's driving me nuts if I'm honest - and I'm pretty certain that it wasn't the case a few months ago (I'm working on this same, multithreaded, partially async codebase since about 5 years now).

@tbrisker-april
Copy link

I've also been encountering the same issue recently, and it seems to be a regression introduced in the recent months, in the past there was no issue debugging a multithreaded app without the debugger jumping to other threads.

@rchiodo
Copy link
Contributor Author

rchiodo commented Jan 6, 2025

This might be a problem only related to 3.12 and above. #1792 indicated it started with the changes for sys.monitoring. I can't reproduce the issue with 3.11.

@rchiodo rchiodo assigned rchiodo and unassigned heejaechang Jan 6, 2025
@rchiodo rchiodo added Fixed in next release This issue has been fixed, but won't be available to customers until the next release. and removed needs repro Issue has not been reproduced yet labels Jan 7, 2025
@xmatthias
Copy link

xmatthias commented Jan 10, 2025

@rchiodo when is the next release planned? (this release will probably even not be sufficient, as i'd need it in the vscode extensions ...)

Considering the fixes in / around "fixed in next release" are quite impacting (IF you're impacted) - i'd apreciate this being fixed pretty short-term - as it makes debugging currently a very frustrating experience.

@rchiodo
Copy link
Contributor Author

rchiodo commented Jan 10, 2025

Next release will probably ship in the next week or so. I'm looking at some matplotlib problems too that I'd like to fix before the next release.

Note that you can "get" the fix yourself by just copying the source from main over your install of debugpy. There were no native changes in this fix, you just need the source code that ships with debupgy.

@rchiodo
Copy link
Contributor Author

rchiodo commented Jan 15, 2025

This issue should be fixed in the latest build of debugpy. It should ship with VS code in a future version of the Python Debugger Extension or you can install your own debugpy from pypi

@rchiodo rchiodo closed this as completed Jan 15, 2025
@rchiodo
Copy link
Contributor Author

rchiodo commented Jan 15, 2025

Take that back, our release to PyPI failed when it looked like it succeeded. Fix will be coming after we resolve that problem.

@rchiodo rchiodo reopened this Jan 15, 2025
@rchiodo
Copy link
Contributor Author

rchiodo commented Jan 16, 2025

PyPI release succeeded. v1.8.12 is now available

@rchiodo rchiodo closed this as completed Jan 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fixed in next release This issue has been fixed, but won't be available to customers until the next release.
Projects
None yet
Development

No branches or pull requests

4 participants