Skip to content

fix(telemetry): allow Python SDK initialization from worker threads - #4971

Open
DivyamTalwar wants to merge 1 commit into
latitude-dev:developmentfrom
DivyamTalwar:fix/telemetry-python-worker-thread-init
Open

DivyamTalwar wants to merge 1 commit into
latitude-dev:developmentfrom
DivyamTalwar:fix/telemetry-python-worker-thread-init

Conversation

@DivyamTalwar

@DivyamTalwar DivyamTalwar commented Nov 30, 2026 •

Copy link
Copy Markdown

The Python telemetry SDK can attach its exporter and then fail during construction because Python only permits signal registration on the main thread. Register the process exit callback once from either thread. If initialization later runs on the main thread, install the original signal handlers using the same first shutdown owner.

A fresh interpreter reproduced the failure while creating Latitude from a real worker thread. The patched subprocess exports a span and verifies a later main-thread initialization retains the first shutdown owner. An independent concurrent run also verified one exit callback and one SIGINT/SIGTERM registration across worker and main initializations.

All 145 telemetry tests passed on the locked Python 3.12 environment. Ruff, targeted Pyright, and the diff check passed. Tests used local in-memory exporters.


Proof this PR
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

Copilot AI balanced review requested due to automatic review settings November 30, 2026 17:52
@vercel

vercel Bot commented Nov 30, 2026

Copy link
Copy Markdown

@DivyamTalwar is attempting to deploy a commit to the Latitude Team on Vercel.

A member of the Team first needs to authorize it.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-30T17:55:22.780714Z 8bd96a7 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

geclos commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Thanks for this, @DivyamTalwar! Allowing the Python SDK to initialize from worker threads is a useful fix, and Codex didn't flag anything. One thing before we can move forward: please sign the CLA by posting a comment with exactly I have read the CLA Document and I hereby sign the CLA (the CLAAssistant check is currently failing). Once that's in, we'll approve the CI workflows for the fork and take a look. Thanks!

@DivyamTalwar

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request Dec 1, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Inbox

Development

Successfully merging this pull request may close these issues.

3 participants