-
Notifications
You must be signed in to change notification settings - Fork 198
Fix debugger hang when expanding objects with blocking property getters (#2053) #2055
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
Merged
Rich Chiodo (rchiodo)
merged 2 commits into
main
from
rchiodo-investigate-repr-hang-2053
Aug 6, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
...bugpy/_vendored/pydevd/tests_python/resources/_debugger_case_deadlock_thread_variables.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| """ | ||
| The idea here is that a secondary thread does the processing of instructions, and an object has a | ||
| property whose getter dispatches work to that secondary thread and blocks waiting for the result. | ||
|
|
||
| So, when all threads are stopped at a breakpoint, *expanding* that object in the variables view (which | ||
| evaluates its properties) would be locked until the secondary thread is allowed to run. | ||
|
|
||
| This mirrors real-world objects such as lancedb's ``LanceDBConnection``, whose property getters block | ||
| on a background asyncio event loop running in a daemon thread. | ||
| """ | ||
|
|
||
| import threading | ||
|
|
||
| try: | ||
| from queue import Queue | ||
| except ImportError: | ||
| from Queue import Queue | ||
|
|
||
|
|
||
| class EchoThread(threading.Thread): | ||
| def __init__(self, queue): | ||
| threading.Thread.__init__(self) | ||
| self.daemon = True | ||
| self._queue = queue | ||
| self.started = threading.Event() | ||
|
|
||
| def run(self): | ||
| self.started.set() | ||
| while True: | ||
| obj = self._queue.get() | ||
| if obj == "finish": | ||
| break | ||
|
|
||
| obj.result = obj.value + 1 | ||
| obj.event.set() # Break here 2 | ||
|
|
||
|
|
||
| class NotificationObject(object): | ||
| def __init__(self, value): | ||
| self.value = value | ||
| self.result = None | ||
| self.event = threading.Event() | ||
|
|
||
|
|
||
| class Connection(object): | ||
| """ | ||
| Mimics a native-backed connection whose property getter dispatches to a background thread and | ||
| blocks on the result (like lancedb's LanceDBConnection). | ||
| """ | ||
|
|
||
| def __init__(self, queue): | ||
| self._queue = queue | ||
| self.storage_options = None | ||
|
|
||
| @property | ||
| def read_consistency_interval(self): | ||
| obj = NotificationObject(41) | ||
| self._queue.put(obj) | ||
| assert obj.event.wait() # Blocks until the (suspended) EchoThread processes the request. | ||
| return obj.result | ||
|
|
||
| def __repr__(self): | ||
| return "Connection(read_consistency_interval=<computed lazily>)" | ||
|
|
||
|
|
||
| def main(): | ||
| queue = Queue() | ||
| echo_thread = EchoThread(queue) | ||
| processor = Connection(queue) | ||
| echo_thread.start() | ||
| echo_thread.started.wait() | ||
|
|
||
| print("stop here") # Break here 1 | ||
|
|
||
| queue.put("finish") | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() | ||
| print("TEST SUCEEDED!") | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.