Skip to content

Commit

Permalink
Add instrumentation::setprofile_all_threads
Browse files Browse the repository at this point in the history
  • Loading branch information
LilyFoote committed Jun 23, 2024
1 parent 2e184e3 commit 3ae8ef4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/instrumentation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ pub fn setprofile<P: Profiler>(profiler: Bound<'_, P>) {
unsafe { ffi::PyEval_SetProfile(Some(profile_callback::<P>), profiler.into_ptr()) };
}

/// Register a custom Profiler with the Python interpreter.
#[cfg(Py_3_12)]
pub fn setprofile_all_threads<P: Profiler>(profiler: Bound<'_, P>) {
unsafe { ffi::PyEval_SetProfileAllThreads(Some(profile_callback::<P>), profiler.into_ptr()) };
}

extern "C" fn profile_callback<P>(
obj: *mut ffi::PyObject,
frame: *mut ffi::PyFrameObject,
Expand Down

0 comments on commit 3ae8ef4

Please sign in to comment.