From 76af5c9153394f3d07562427168711a68f54ec66 Mon Sep 17 00:00:00 2001 From: Pablo Galindo Date: Thu, 8 Sep 2022 11:58:48 +0100 Subject: [PATCH 1/5] gh-93503: Document the new tracing/profiling APIs in the What's new document --- Doc/whatsnew/3.12.rst | 14 ++++++++++++++ .../2022-06-06-16-04-14.gh-issue-93503.MHJTu8.rst | 12 ++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/Doc/whatsnew/3.12.rst b/Doc/whatsnew/3.12.rst index 70a1104127e9a8..f9d852dc431fbe 100644 --- a/Doc/whatsnew/3.12.rst +++ b/Doc/whatsnew/3.12.rst @@ -136,6 +136,14 @@ sqlite3 * Add a :ref:`command-line interface `. (Contributed by Erlend E. Aasland in :gh:`77617`.) +threading +--------- + +* Add :func:`threading.settrace_all_threads` and + :func:`threading.setprofile_all_threads` that allow to set tracking and + profiling functions in all running threads in addition to the calling one. + (Contributed by Pablo Galindo in :gh:`93503`.) + Optimizations ============= @@ -470,6 +478,12 @@ New Features ``__dict__`` and weakrefs with less bookkeeping, using less memory and with faster access. +* Added two new public functions to the public C-API, + :c:func:`PyEval_SetProfileAllThreads` and + :c:func:`PyEval_SetTraceAllThreads`, that allow to set tracking and profiling + functions in all running threads in addition to the calling one. (Contributed + by Pablo Galindo in :gh:`93503`.) + Porting to Python 3.12 ---------------------- diff --git a/Misc/NEWS.d/next/C API/2022-06-06-16-04-14.gh-issue-93503.MHJTu8.rst b/Misc/NEWS.d/next/C API/2022-06-06-16-04-14.gh-issue-93503.MHJTu8.rst index 6df9f95fc9461d..5a51ae77471d70 100644 --- a/Misc/NEWS.d/next/C API/2022-06-06-16-04-14.gh-issue-93503.MHJTu8.rst +++ b/Misc/NEWS.d/next/C API/2022-06-06-16-04-14.gh-issue-93503.MHJTu8.rst @@ -1,7 +1,7 @@ Add two new public functions to the public C-API, -:c:func:`PyEval_SetProfileAllThreads` and -:c:func:`PyEval_SetTraceAllThreads`, that allow to set tracking and -profiling functions in all running threads in addition to the calling one. -Also, add a new *running_threads* parameter to :func:`threading.setprofile` -and :func:`threading.settrace` that allows to do the same from Python. Patch -by Pablo Galindo +:c:func:`PyEval_SetProfileAllThreads` and :c:func:`PyEval_SetTraceAllThreads`, +that allow to set tracking and profiling functions in all running threads in +addition to the calling one. Also, two analogous functions to the +:mod:`threading` module (:func:`threading.setprofile_all_threads` and +:func:`threading.settrace_all_threads`) that allow to do the same from Python. +Patch by Pablo Galindo From 4b787a421ff4db5ee55efe0bcc999e126ddcc0ad Mon Sep 17 00:00:00 2001 From: Pablo Galindo Salgado Date: Tue, 13 Sep 2022 11:07:48 +0100 Subject: [PATCH 2/5] Update Doc/whatsnew/3.12.rst Co-authored-by: Victor Stinner --- Doc/whatsnew/3.12.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/whatsnew/3.12.rst b/Doc/whatsnew/3.12.rst index f9d852dc431fbe..d4ea6761dc15b4 100644 --- a/Doc/whatsnew/3.12.rst +++ b/Doc/whatsnew/3.12.rst @@ -478,7 +478,7 @@ New Features ``__dict__`` and weakrefs with less bookkeeping, using less memory and with faster access. -* Added two new public functions to the public C-API, +* Added two new public functions, :c:func:`PyEval_SetProfileAllThreads` and :c:func:`PyEval_SetTraceAllThreads`, that allow to set tracking and profiling functions in all running threads in addition to the calling one. (Contributed From d5bd4763da0bca6d6f1626ae8eb4f7f5e22e01a8 Mon Sep 17 00:00:00 2001 From: Pablo Galindo Salgado Date: Tue, 13 Sep 2022 11:07:57 +0100 Subject: [PATCH 3/5] Update Doc/whatsnew/3.12.rst Co-authored-by: Victor Stinner --- Doc/whatsnew/3.12.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/whatsnew/3.12.rst b/Doc/whatsnew/3.12.rst index d4ea6761dc15b4..06c8504dfc6f52 100644 --- a/Doc/whatsnew/3.12.rst +++ b/Doc/whatsnew/3.12.rst @@ -140,7 +140,7 @@ threading --------- * Add :func:`threading.settrace_all_threads` and - :func:`threading.setprofile_all_threads` that allow to set tracking and + :func:`threading.setprofile_all_threads` that allow to set tracing and profiling functions in all running threads in addition to the calling one. (Contributed by Pablo Galindo in :gh:`93503`.) From 7847e780283028c3e3312086c4f3a29aeb29377d Mon Sep 17 00:00:00 2001 From: Pablo Galindo Salgado Date: Tue, 13 Sep 2022 12:46:46 +0100 Subject: [PATCH 4/5] Update Misc/NEWS.d/next/C API/2022-06-06-16-04-14.gh-issue-93503.MHJTu8.rst Co-authored-by: Victor Stinner --- .../next/C API/2022-06-06-16-04-14.gh-issue-93503.MHJTu8.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/C API/2022-06-06-16-04-14.gh-issue-93503.MHJTu8.rst b/Misc/NEWS.d/next/C API/2022-06-06-16-04-14.gh-issue-93503.MHJTu8.rst index 5a51ae77471d70..3dd292cd778023 100644 --- a/Misc/NEWS.d/next/C API/2022-06-06-16-04-14.gh-issue-93503.MHJTu8.rst +++ b/Misc/NEWS.d/next/C API/2022-06-06-16-04-14.gh-issue-93503.MHJTu8.rst @@ -1,6 +1,6 @@ Add two new public functions to the public C-API, :c:func:`PyEval_SetProfileAllThreads` and :c:func:`PyEval_SetTraceAllThreads`, -that allow to set tracking and profiling functions in all running threads in +that allow to set tracing and profiling functions in all running threads in addition to the calling one. Also, two analogous functions to the :mod:`threading` module (:func:`threading.setprofile_all_threads` and :func:`threading.settrace_all_threads`) that allow to do the same from Python. From 7449b9b8d2d3e5d20e9c6a9a800abfaa9d2ef503 Mon Sep 17 00:00:00 2001 From: Pablo Galindo Salgado Date: Tue, 13 Sep 2022 12:46:50 +0100 Subject: [PATCH 5/5] Update Doc/whatsnew/3.12.rst Co-authored-by: Victor Stinner --- Doc/whatsnew/3.12.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/whatsnew/3.12.rst b/Doc/whatsnew/3.12.rst index 06c8504dfc6f52..b87e3643957f38 100644 --- a/Doc/whatsnew/3.12.rst +++ b/Doc/whatsnew/3.12.rst @@ -480,7 +480,7 @@ New Features * Added two new public functions, :c:func:`PyEval_SetProfileAllThreads` and - :c:func:`PyEval_SetTraceAllThreads`, that allow to set tracking and profiling + :c:func:`PyEval_SetTraceAllThreads`, that allow to set tracing and profiling functions in all running threads in addition to the calling one. (Contributed by Pablo Galindo in :gh:`93503`.)