Skip to content

bpo-37266: Daemon threads are now denied in subinterpreters - #14049

Merged
vstinner merged 4 commits into
python:masterfrom
vstinner:subinterp_daemon_thread
Jun 14, 2019
Merged

vstinner merged 4 commits into
python:masterfrom
vstinner:subinterp_daemon_thread

Conversation

@vstinner

@vstinner vstinner commented Jun 13, 2019 •

Copy link
Copy Markdown
Member

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 the new function.
  • Use textwrap.dedent() in test_threading.SubinterpThreadingTests

https://bugs.python.org/issue37266

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 the new function.
* Use textwrap.dedent() in test_threading.SubinterpThreadingTests
@vstinner vstinner changed the title bpo-37266: Daemon threads are now defined in subinterpreters Jun 13, 2019
@vstinner

vstinner commented Jun 13, 2019 •

Copy link
Copy Markdown
Member Author

Oops. Typo in my PR title: "bpo-37266: Daemon threads are now denied in subinterpreters".

@vstinner

Copy link
Copy Markdown
Member Author

Add _thread._is_main_interpreter()

I chose to add the new function the _thread module to not add a dependency (import) between thread and . For example, I would prefer that threading doesn't import _xxsubintepreters. The module is private, its API is a work-in-progress and it may pull other things which are not needed by threads.

vstinner added 3 commits June 14, 2019 16:29
* use print() using flush=True
* make the read end of the pipe non-blocking to avoid hanging forever
@vstinner
vstinner merged commit 066e5b1 into python:master Jun 14, 2019
@vstinner
vstinner deleted the subinterp_daemon_thread branch June 14, 2019 16:56
lisroach pushed a commit to lisroach/cpython that referenced this pull request Sep 10, 2019
…-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
DinoV pushed a commit to DinoV/cpython that referenced this pull request Jan 14, 2020
…-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
vstinner added a commit that referenced this pull request Apr 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants