◐ Shell
clean mode source ↗

Use parking_lot in faulthandler by youknowone · Pull Request #6438 · RustPython/RustPython

Caution

Review failed

The pull request is closed.

Walkthrough

Replaced std::sync::Mutex and Condvar with parking_lot equivalents throughout crates/stdlib/src/faulthandler.rs. Changed unwrap-based lock acquisitions to direct lock calls, updated condition variable wait patterns from wait_timeout to wait_for, and adjusted guard handling in the WATCHDOG state and unix-specific user_signals submodule. No public API changes.

Changes

Cohort / File(s) Summary
Synchronization primitives migration
crates/stdlib/src/faulthandler.rs
Replaced std::sync::Mutex and Condvar with parking_lot equivalents; converted unwrap-based lock acquisitions to non-panicking lock() calls; updated condition variable wait_timeout to wait_for; refactored WATCHDOG state initialization and mutation; adjusted unix-specific user_signals module (get_user_signal, set_user_signal, clear_user_signal, is_enabled) to use parking_lot::Mutex

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Verify parking_lot API semantics: Ensure lock(), wait_for(), and guard handling match previous std::sync behavior and do not introduce unexpected differences in timeout or blocking semantics
  • WATCHDOG state mutations: Confirm all WATCHDOG state access patterns are correctly updated and thread-safe
  • Condition variable semantics: Validate that wait_for() timeout behavior is equivalent to the previous wait_timeout() pattern
  • Guard scope and lifetime: Review all guard variable scope changes to ensure no new deadlock or guard drop timing issues

Possibly related PRs

  • Faulthandler #6400 — Introduces Watchdog/WATCHDOG synchronization mechanisms in faulthandler.rs; this PR updates those same lock primitives to use parking_lot
  • Faulthandler #6406 — Modifies faulthandler.rs state and handler code; this PR refactors synchronization for the same module

Suggested reviewers

  • ShaharNaveh

Poem

🐰 The parking lot beckons, no waits in sight,
Mutexes swapped for speed, threading feels light,
No unwrapping panics on these guarded doors,
Fault handlers synced—now running much more!

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8e21db1 and 63d2c66.

📒 Files selected for processing (1)
  • crates/stdlib/src/faulthandler.rs (8 hunks)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.