diff options
author | Victor Stinner <vstinner@python.org> | 2020-03-20 12:38:58 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-20 12:38:58 (GMT) |
commit | d2a8e5b42c5e9c4e745a0589043a8aebb49f8ca2 (patch) | |
tree | bf76400eb6529986ba4319faf4664a70a7303869 /Doc | |
parent | da2914db4b6f786a1e9f0b424efeeb6ca9418912 (diff) | |
download | cpython-d2a8e5b42c5e9c4e745a0589043a8aebb49f8ca2.zip cpython-d2a8e5b42c5e9c4e745a0589043a8aebb49f8ca2.tar.gz cpython-d2a8e5b42c5e9c4e745a0589043a8aebb49f8ca2.tar.bz2 |
bpo-40010: COMPUTE_EVAL_BREAKER() checks for subinterpreter (GH-19087)
COMPUTE_EVAL_BREAKER() now also checks if the Python thread state
belongs to the main interpreter. Don't break the evaluation loop if
there are pending signals but the Python thread state it belongs to a
subinterpeter.
* Add _Py_IsMainThread() function.
* Add _Py_ThreadCanHandleSignals() function.
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/signal.rst | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/Doc/library/signal.rst b/Doc/library/signal.rst index 8b3ab41..4353cc7 100644 --- a/Doc/library/signal.rst +++ b/Doc/library/signal.rst @@ -53,12 +53,12 @@ This has consequences: Signals and threads ^^^^^^^^^^^^^^^^^^^ -Python signal handlers are always executed in the main Python thread, +Python signal handlers are always executed in the main Python thread of the main interpreter, even if the signal was received in another thread. This means that signals can't be used as a means of inter-thread communication. You can use the synchronization primitives from the :mod:`threading` module instead. -Besides, only the main thread is allowed to set a new signal handler. +Besides, only the main thread of the main interpreter is allowed to set a new signal handler. Module contents @@ -266,7 +266,7 @@ The :mod:`signal` module defines the following functions: same process as the caller. The target thread can be executing any code (Python or not). However, if the target thread is executing the Python interpreter, the Python signal handlers will be :ref:`executed by the main - thread <signals-and-threads>`. Therefore, the only point of sending a + thread of the main interpreter <signals-and-threads>`. Therefore, the only point of sending a signal to a particular Python thread would be to force a running system call to fail with :exc:`InterruptedError`. @@ -360,7 +360,8 @@ The :mod:`signal` module defines the following functions: If not -1, *fd* must be non-blocking. It is up to the library to remove any bytes from *fd* before calling poll or select again. - When threads are enabled, this function can only be called from the main thread; + When threads are enabled, this function can only be called + from :ref:`the main thread of the main interpreter <signals-and-threads>`; attempting to call it from other threads will cause a :exc:`ValueError` exception to be raised. @@ -413,7 +414,8 @@ The :mod:`signal` module defines the following functions: signal handler will be returned (see the description of :func:`getsignal` above). (See the Unix man page :manpage:`signal(2)` for further information.) - When threads are enabled, this function can only be called from the main thread; + When threads are enabled, this function can only be called + from :ref:`the main thread of the main interpreter <signals-and-threads>`; attempting to call it from other threads will cause a :exc:`ValueError` exception to be raised. |