Bug: Thread cleanup exception during interpreter shutdown when using VS Code debugger
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 38/100
Research direction
Start by reproducing the provided script under the VS Code debugger and compare it with a normal python script.py run. Investigate debugger-managed threads and interpreter shutdown cleanup around _DeleteDummyThreadOnDel.__del__; done means the debugger run exits without the reported TypeError.
Written by the indexing model from the issue text.
Description
📌 Environment
- Python Version: 3.13.5
- OS: Windows 11
- Debugger: VS Code (debugpy)
📝 Description
When running code under the VS Code debugger, an exception is raised during interpreter shutdown:
Exception ignored in: <function _DeleteDummyThreadOnDel.__del__>
Traceback (most recent call last):
File ".../threading.py", line 1385, in __del__
TypeError: 'NoneType' object does not support the context manager protocol
🔍 Key Observation
- ❌ Does NOT occur when running normally (
python script.py) - ✅ Only occurs when running via VS Code debugger
🧪 Steps to Reproduce
from strands import Agent, tool
from strands_tools import http_request
import boto3
from strands.models import BedrockModel
session = boto3.Session(region_name="us-east-1")
model = BedrockModel(
model_id="your-model-id",
boto_session=session
)
@tool
def dummy_tool(text: str) -> str:
return text
agent = Agent(
system_prompt="Test agent",
tools=[http_request, dummy_tool],
model=model
)
agent("Test request")
print("DONE EXECUTION")
📤 Observed Output (Debugger Only)
DONE EXECUTION
Exception ignored in: <function _DeleteDummyThreadOnDel.__del__>
Traceback (most recent call last):
File ".../threading.py", line ...
TypeError: 'NoneType' object does not support the context manager protocol
✅ Expected Behavior
No exception during interpreter shutdown in debugger mode.
❌ Actual Behavior
Thread cleanup triggers a TypeError during interpreter shutdown when running under debugger.
📎 Notes
- Likely related to debugger-managed threads and interpreter shutdown order
- Possibly occurs when threads outlive global state during teardown
- Does not impact runtime correctness
🛠️ Workarounds
- Running script outside debugger avoids issue
- Adding delays (
time.sleep) reduces occurrence but does not fully eliminate
📌 Summary
This appears to be a debugger-related threading cleanup issue during interpreter shutdown in Python 3.13.
- Dominant language
- Python
- Stars
- 2.5k
- Forks
- 202
- Avg merge
- 5d 1h
- Merged PRs (30d)
- 1
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/debugpy
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
All issues in microsoft/debugpy
Similar issues
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
canonical/paas-charm#368 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
tech debt
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
StevenBlack/hosts#3256 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
qualcomm/qai-appbuilder#275 ·