-
Notifications
You must be signed in to change notification settings - Fork 191
Bug: Thread cleanup exception during interpreter shutdown when using VS Code debugger #2016
Copy link
Copy link
Open
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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels