Skip to content

Conversation

pingsutw
Copy link
Member

@pingsutw pingsutw commented Aug 8, 2025

Why are the changes needed?

No log or stack trace when the task is hanging.

What changes were proposed in this pull request?

Register a signal handler, so that we can see the stacktrace when the task gets killed

How was this patch tested?

Run a task, and kill the pod.

Locally,

$ cat > x.py
import faulthandler
import signal
faulthandler.register(signal.SIGUSR1)
import asyncio
asyncio.run(asyncio.sleep(100))
^C
$ python x.py &
[1] 68306
$ kill -USR1 68306
Current thread 0x00000001f8b74c80 (most recent call first):
  File "/Users/ytong/.local/share/uv/python/cpython-3.13.1-macos-aarch64-none/lib/python3.13/selectors.py", line 548 in select
  File %                                                                                                                                                                   "/Users/ytong/.local/share/uv/python/cpython-3.13.1-macos-aarch64-none/lib/python3.13/asyncio/base_events.py", line 1995 in _run_once
  File "/Users/ytong/.local/share/uv/python/cpython-3.13.1-macos-aarch64-none/lib/python3.13/asyncio/base_events.py", line 678 in run_forever
  File "/Users/ytong/.local/share/uv/python/cpython-3.13.1-macos-aarch64-none/lib/python3.13/asyncio/base_events.py", line 707 in run_until_complete
  File "/Users/ytong/.local/share/uv/python/cpython-3.13.1-macos-aarch64-none/lib/python3.13/asyncio/runners.py", line 118 in run
  File "/Users/ytong/.local/share/uv/python/cpython-3.13.1-macos-aarch64-none/lib/python3.13/asyncio/runners.py", line 194 in run
  File "/Users/ytong/x.py", line 5 in <module>

Setup process

Screenshots

Check all the applicable boxes

  • I updated the documentation accordingly.
  • All new and existing tests passed.
  • All commits are signed-off.

Related PRs

Docs link

Summary by Bito

This pull request enhances signal handling in the Flytekit library by registering the faulthandler for SIGUSR1, enabling stack trace capture for better debugging when tasks hang or are terminated.

@pingsutw pingsutw merged commit 6614d4c into master Aug 21, 2025
226 of 228 checks passed
Atharva1723 pushed a commit to Atharva1723/flytekit that referenced this pull request Oct 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants