Skip to content

fix: /thread_dump endpoint returns 500 due to faulthandler requiring real file descriptor #1426

@iplay88keys

Description

@iplay88keys

The /thread_dump endpoint fails with io.UnsupportedOperation: fileno:

File "/.kagent/packages/kagent-adk/src/kagent/adk/_a2a.py", line 48, in thread_dump
    faulthandler.dump_traceback(file=buf)
io.UnsupportedOperation: fileno

faulthandler.dump_traceback() writes at the C level and requires a real OS file descriptor. The current code passes io.StringIO() which doesn't have one.

Fix: Use tempfile.TemporaryFile(mode="w+") instead of StringIO, and add all_threads=True to capture all thread stacks.

This endpoint is useful for diagnosing CPU spin issues like #1073 — a thread dump from a spinning pod would show exactly which thread is busy-looping.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

Backlog

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions