summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorPablo Galindo Salgado <Pablogsal@gmail.com>2022-08-24 22:21:39 (GMT)
committerGitHub <noreply@github.com>2022-08-24 22:21:39 (GMT)
commite34c82abeb7ace09e6b5d116585c47cc372996c1 (patch)
tree16f130870af42de041ddf52a36540b9c421aec8c /Doc
parent657976ad950e56b33b7dc15e64a0baecdd184f5a (diff)
downloadcpython-e34c82abeb7ace09e6b5d116585c47cc372996c1.zip
cpython-e34c82abeb7ace09e6b5d116585c47cc372996c1.tar.gz
cpython-e34c82abeb7ace09e6b5d116585c47cc372996c1.tar.bz2
GH-93503: Add thread-specific APIs to set profiling and tracing functions in the C-API (#93504)
* gh-93503: Add APIs to set profiling and tracing functions in all threads in the C-API * Use a separate API * Fix NEWS entry * Add locks around the loop * Document ignoring exceptions * Use the new APIs in the sys module * Update docs
Diffstat (limited to 'Doc')
-rw-r--r--Doc/c-api/init.rst24
-rw-r--r--Doc/data/refcounts.dat8
-rw-r--r--Doc/library/threading.rst18
3 files changed, 50 insertions, 0 deletions
diff --git a/Doc/c-api/init.rst b/Doc/c-api/init.rst
index 038498f..2a9cf0e 100644
--- a/Doc/c-api/init.rst
+++ b/Doc/c-api/init.rst
@@ -1774,6 +1774,18 @@ Python-level trace functions in previous versions.
The caller must hold the :term:`GIL`.
+.. c:function:: void PyEval_SetProfileAllThreads(Py_tracefunc func, PyObject *obj)
+
+ Like :c:func:`PyEval_SetProfile` but sets the profile function in all running threads
+ belonging to the current interpreter instead of the setting it only on the current thread.
+
+ The caller must hold the :term:`GIL`.
+
+ As :c:func:`PyEval_SetProfile`, this function ignores any exceptions raised while
+ setting the profile functions in all threads.
+
+.. versionadded:: 3.12
+
.. c:function:: void PyEval_SetTrace(Py_tracefunc func, PyObject *obj)
@@ -1788,6 +1800,18 @@ Python-level trace functions in previous versions.
The caller must hold the :term:`GIL`.
+.. c:function:: void PyEval_SetTraceAllThreads(Py_tracefunc func, PyObject *obj)
+
+ Like :c:func:`PyEval_SetTrace` but sets the tracing function in all running threads
+ belonging to the current interpreter instead of the setting it only on the current thread.
+
+ The caller must hold the :term:`GIL`.
+
+ As :c:func:`PyEval_SetTrace`, this function ignores any exceptions raised while
+ setting the trace functions in all threads.
+
+.. versionadded:: 3.12
+
.. _advanced-debugging:
diff --git a/Doc/data/refcounts.dat b/Doc/data/refcounts.dat
index 1694cad..51ccacf 100644
--- a/Doc/data/refcounts.dat
+++ b/Doc/data/refcounts.dat
@@ -796,10 +796,18 @@ PyEval_SetProfile:void:::
PyEval_SetProfile:Py_tracefunc:func::
PyEval_SetProfile:PyObject*:obj:+1:
+PyEval_SetProfileAllThreads:void:::
+PyEval_SetProfileAllThreads:Py_tracefunc:func::
+PyEval_SetProfileAllThreads:PyObject*:obj:+1:
+
PyEval_SetTrace:void:::
PyEval_SetTrace:Py_tracefunc:func::
PyEval_SetTrace:PyObject*:obj:+1:
+PyEval_SetTraceAllThreads:void:::
+PyEval_SetTraceAllThreads:Py_tracefunc:func::
+PyEval_SetTraceAllThreads:PyObject*:obj:+1:
+
PyEval_EvalCode:PyObject*::+1:
PyEval_EvalCode:PyObject*:co:0:
PyEval_EvalCode:PyObject*:globals:0:
diff --git a/Doc/library/threading.rst b/Doc/library/threading.rst
index b22d487..b352125 100644
--- a/Doc/library/threading.rst
+++ b/Doc/library/threading.rst
@@ -158,6 +158,15 @@ This module defines the following functions:
The *func* will be passed to :func:`sys.settrace` for each thread, before its
:meth:`~Thread.run` method is called.
+.. function:: settrace_all_threads(func)
+
+ Set a trace function for all threads started from the :mod:`threading` module
+ and all Python threads that are currently executing.
+
+ The *func* will be passed to :func:`sys.settrace` for each thread, before its
+ :meth:`~Thread.run` method is called.
+
+ .. versionadded:: 3.12
.. function:: gettrace()
@@ -178,6 +187,15 @@ This module defines the following functions:
The *func* will be passed to :func:`sys.setprofile` for each thread, before its
:meth:`~Thread.run` method is called.
+.. function:: setprofile_all_threads(func)
+
+ Set a profile function for all threads started from the :mod:`threading` module
+ and all Python threads that are currently executing.
+
+ The *func* will be passed to :func:`sys.setprofile` for each thread, before its
+ :meth:`~Thread.run` method is called.
+
+ .. versionadded:: 3.12
.. function:: getprofile()