Bug: Thread cleanup exception during interpreter shutdown when using VS Code debugger
还没有人认领这个 Issue。
评估
调研方向
首先,在 VS Code 调试器下复现提供的脚本,并将其与正常运行 python script.py 的结果进行比较。调查调试器管理的线程,以及围绕 _DeleteDummyThreadOnDel.__del__ 的解释器关闭清理;当调试器运行在没有报告的 TypeError 的情况下退出时,即视为完成。
由索引模型根据 Issue 内容生成。
描述
📌 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.
- 主要语言
- Python
- 星标
- 2.5k
- 派生
- 202
- 平均合并
- 5 天 1 小时
- 30 天内合并 PR
- 1
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/debugpy 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
-
documentation
难度 2/5 1-3 小时 新手友好度 68/100
-
难度 2/5 1-3 小时 新手友好度 78/100
-
documentation
难度 2/5 1-3 小时 新手友好度 62/100
-
难度 3/5 1-2 天 新手友好度 68/100
查看 microsoft/debugpy 的全部 Issue
相似的 Issue
-
essnmx good first issue
难度 1/5 1 小时以内 新手友好度 95/100
-
难度 2/5 1-3 小时 新手友好度 65/100
syfoud/Simulated_Scepter#174 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
Giskard-AI/giskard-oss#2840 · 1 条评论 ·
-
A claim comment carrying the issue number is silently declined while the workflow reports success 未关闭area: repo bug perceived difficulty: 2
难度 2/5 1-3 小时 新手友好度 70/100
-
难度 2/5 1-3 小时 新手友好度 75/100
yeti-platform/yeti#1380 ·