Currently, daemon threads completely segfault if a thread decides to create a subinterpreter:
import threading
import _interpreters
def main():
_interpreters.create()
threading.Thread(target=main, daemon=True).start()
Disallowing daemon threads only inside subinterpreters won’t fix this problem. Really, what we need is a better way for daemon threads to communicate with the main thread and find the right time to shut themselves down. The situation right now is that finalizing the main interpreter prevents future re-acquiring of the GIL, which is fine normally, but since subinterpreters can have their own GIL, this doesn’t end up blocking them and they crash. (I’m not sure how free-threading addresses this, but maybe it’s something that we could borrow for the default build.)