Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Bug: Thread cleanup exception during interpreter shutdown when using VS Code debugger

未关闭
#2,016 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
38/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
冷清
技术栈
python
领域
devtools

调研方向

首先,在 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

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

microsoft/debugpy 的其他 Issue

查看 microsoft/debugpy 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。