Skip to content

Conversation

@ShaharNaveh
Copy link
Collaborator

@ShaharNaveh ShaharNaveh commented Dec 12, 2025

Summary by CodeRabbit

  • New Features
    • Added a new sys module function to query Global Interpreter Lock (GIL) status. Users can now check the GIL implementation state programmatically.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 12, 2025

Walkthrough

A new _is_gil_enabled() function was added to the sys module as a Python-exposed const function that returns false, indicating the GIL is not implemented in this environment.

Changes

Cohort / File(s) Summary
GIL Status Function
crates/vm/src/stdlib/sys.rs
Added new #[pyfunction] const fn _is_gil_enabled() -> bool that returns false to signal GIL is not available

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Suggested reviewers

  • youknowone

Poem

🐰 A GIL check hops into sys today,
Returns false in a gentle way,
No locks will bind these concurrent threads,
Freedom in code, the rabbit thread spreads! 🧵✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Title check ⚠️ Warning The title mentions updating test_sys.py from 3.13.11, but the actual changes add a new _is_gil_enabled() function to the sys module implementation, not test updates. Update the title to accurately reflect the main change, such as 'Add _is_gil_enabled() function to sys module' or similar.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ 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 e227956 and 97457ce.

⛔ Files ignored due to path filters (1)
  • Lib/test/test_sys.py is excluded by !Lib/**
📒 Files selected for processing (1)
  • crates/vm/src/stdlib/sys.rs (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.rs: Follow the default rustfmt code style by running cargo fmt to format Rust code
Always run clippy to lint Rust code (cargo clippy) before completing tasks and fix any warnings or lints introduced by changes
Follow Rust best practices for error handling and memory management
Use the macro system (pyclass, pymodule, pyfunction, etc.) when implementing Python functionality in Rust

Files:

  • crates/vm/src/stdlib/sys.rs
🧠 Learnings (1)
📚 Learning: 2025-06-27T14:47:28.810Z
Learnt from: moreal
Repo: RustPython/RustPython PR: 5847
File: vm/src/stdlib/stat.rs:547-567
Timestamp: 2025-06-27T14:47:28.810Z
Learning: In RustPython's stat module implementation, platform-specific constants like SF_SUPPORTED and SF_SYNTHETIC should be conditionally declared only for the platforms where they're available (e.g., macOS), following CPython's approach of optional declaration using #ifdef checks rather than providing fallback values for other platforms.

Applied to files:

  • crates/vm/src/stdlib/sys.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Run snippets and cpython tests (windows-latest)
  • GitHub Check: Check Rust code with clippy
  • GitHub Check: auto_format
🔇 Additional comments (1)
crates/vm/src/stdlib/sys.rs (1)

334-337: Implementation is correct and ready.

The function signature matches CPython 3.13's sys._is_gil_enabled() -> bool, and the return value of false is appropriate for RustPython since it does not implement the GIL. The use of const fn is correct for a constant return value, and the implementation is consistent with similar const functions in the file (e.g., getdefaultencoding()), which also have no docstring.


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.


# TODO: RUSTPYTHON, AtExit.__del__ is not invoked because module destruction is missing.
@unittest.expectedFailure
@unittest.expectedFailure # TODO: RUSTPYTHON; AssertionError: False is not true
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It seems like

sysconfig.get_config_var('Py_GIL_DISABLED')

returns None (should return 1)

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.

1 participant