refactor(internal): use fork-safe locks and threads consistently - #19796
refactor(internal): use fork-safe locks and threads consistently#19796P403n1x87 wants to merge 3 commits into
Conversation
🎉 All green!🧪 All tests passed 🔗 Commit SHA: 8d74be3 | Docs | View more details | Give us feedback! |
Circular import analysis
|
Dependency direction analysis
|
Codeowners resolved asResolved from the full PR diff against |
There was a problem hiding this comment.
A fork can restart a completed prompt refresh thread in both the parent and child. This can send duplicate refresh requests and can remove the record for a newer refresh.
🤖 Datadog Autotest · Commit a6d8b87 · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a6d8b878d5
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
BenchmarksBenchmark execution time: 2026-08-21 13:32:13 Comparing candidate commit 8d74be3 in PR branch Found 0 performance improvements and 11 performance regressions! Performance is the same for 607 metrics, 10 unstable metrics.
|
a6d8b87 to
68c8cf2
Compare
Several modules still constructed threading.Lock/RLock or threading.Thread directly. Mixing those with the library's own real OS threads can deadlock. Switch remaining call sites to ddtrace.internal.threads' fork-safe Lock/RLock, and replace llmobs' PromptManager background refresh thread with a new Thread helper built on the existing fork-safe PeriodicThread/PERIODIC_STOP machinery.
68c8cf2 to
5b07af6
Compare
There was a problem hiding this comment.
A one-shot start queued during a fork runs in both processes. Prompt refresh threads also enter an exit join with no time limit, so a stalled HTTP call can block shutdown.
🤖 Datadog Autotest · Commit d4f0832 · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest
Description
Several modules still constructed threading.Lock/RLock or threading.Thread directly. Mixing those with the library's own real OS threads can deadlock. Switch remaining call sites to ddtrace.internal.threads' fork-safe Lock/RLock, and replace llmobs' PromptManager background refresh thread with a new Thread helper built on the existing fork-safe PeriodicThread/PERIODIC_STOP machinery.