Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

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

Open
#2,016 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
38/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
python
Domain
devtools

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/debugpy

All issues in microsoft/debugpy

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.