Skip to content

Commit

Permalink
detect GIL in python 3.13
Browse files Browse the repository at this point in the history
  • Loading branch information
benfred committed Oct 30, 2024
1 parent 7a384e9 commit 63b82e4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/python_interpreters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,9 @@ impl InterpreterState for v3_13_0::PyInterpreterState {
fn head(&self) -> *mut Self::ThreadState {
self.threads.head
}
fn gil_locked(&self) -> Option<bool> {
Some(self._gil.locked != 0)
}
fn modules(&self) -> *mut Self::Object {
self.imports.modules
}
Expand Down
9 changes: 9 additions & 0 deletions src/python_process_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,15 @@ pub fn get_threadstate_address(
config: &Config,
) -> Result<usize, Error> {
let threadstate_address = match version {
Version {
major: 3,
minor: 13,
..
} => {
let interp: v3_13_0::_is = Default::default();
let offset = crate::utils::offset_of(&interp, &interp._gil.last_holder);
interpreter_address + offset
}
Version {
major: 3,
minor: 12,
Expand Down
5 changes: 0 additions & 5 deletions tests/integration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@
# (doesn't seem to be working quite right - TODO: investigate)
GIL = ["--gil"] if not sys.platform.startswith("win") else []

# also disable GIL checks on python 3.12+ for now
if sys.version_info.major == 3 or sys.version_info.minor >= 12:
GIL = []


PYSPY = which("py-spy")


Expand Down

0 comments on commit 63b82e4

Please sign in to comment.