Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(temporal): dump worker thread stacks on SIGUSR1 (#124497)

Jimmy Zhu83ee21e5adc1
diff --git a/posthog/management/commands/start_temporal_worker.py b/posthog/management/commands/start_temporal_worker.py
index 5328e5c6cd84..84748d535cf7 100644
--- a/posthog/management/commands/start_temporal_worker.py
+++ b/posthog/management/commands/start_temporal_worker.py
@@ -852,6 +852,9 @@ class Command(BaseCommand):
# enable faulthandler to print stack traces on segfaults
faulthandler.enable()
+ # `kill -USR1 <pid>` dumps every thread's stack to stderr and leaves the worker running. It
+ # works while a thread holds the GIL, and in containers where py-spy cannot ptrace.
+ faulthandler.register(signal.SIGUSR1)
metrics_port = int(options["metrics_port"])