diff options
author | Victor Stinner <vstinner@redhat.com> | 2019-06-14 16:55:22 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-14 16:55:22 (GMT) |
commit | 066e5b1a917ec2134e8997d2cadd815724314252 (patch) | |
tree | 963b0b6d7d2ae0c580aa48da0d1423930bf2a32d /Modules/clinic | |
parent | 212646cae6b7c4ddc8d98c8b9b6d39a5f259e864 (diff) | |
download | cpython-066e5b1a917ec2134e8997d2cadd815724314252.zip cpython-066e5b1a917ec2134e8997d2cadd815724314252.tar.gz cpython-066e5b1a917ec2134e8997d2cadd815724314252.tar.bz2 |
bpo-37266: Daemon threads are now denied in subinterpreters (GH-14049)
In a subinterpreter, spawning a daemon thread now raises an
exception. Daemon threads were never supported in subinterpreters.
Previously, the subinterpreter finalization crashed with a Pyton
fatal error if a daemon thread was still running.
* Add _thread._is_main_interpreter()
* threading.Thread.start() now raises RuntimeError if the thread is a
daemon thread and the method is called from a subinterpreter.
* The _thread module now uses Argument Clinic for the new function.
* Use textwrap.dedent() in test_threading.SubinterpThreadingTests
Diffstat (limited to 'Modules/clinic')
-rw-r--r-- | Modules/clinic/_threadmodule.c.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/Modules/clinic/_threadmodule.c.h b/Modules/clinic/_threadmodule.c.h new file mode 100644 index 0000000..07ea08b --- /dev/null +++ b/Modules/clinic/_threadmodule.c.h @@ -0,0 +1,22 @@ +/*[clinic input] +preserve +[clinic start generated code]*/ + +PyDoc_STRVAR(_thread__is_main_interpreter__doc__, +"_is_main_interpreter($module, /)\n" +"--\n" +"\n" +"Return True if the current interpreter is the main Python interpreter."); + +#define _THREAD__IS_MAIN_INTERPRETER_METHODDEF \ + {"_is_main_interpreter", (PyCFunction)_thread__is_main_interpreter, METH_NOARGS, _thread__is_main_interpreter__doc__}, + +static PyObject * +_thread__is_main_interpreter_impl(PyObject *module); + +static PyObject * +_thread__is_main_interpreter(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _thread__is_main_interpreter_impl(module); +} +/*[clinic end generated code: output=505840d1b9101789 input=a9049054013a1b77]*/ |