Wait until the Python thread state of all non-daemon threads get deleted.
()
| 1557 | _main_thread = _MainThread() |
| 1558 | |
| 1559 | def _shutdown(): |
| 1560 | """ |
| 1561 | Wait until the Python thread state of all non-daemon threads get deleted. |
| 1562 | """ |
| 1563 | # Obscure: other threads may be waiting to join _main_thread. That's |
| 1564 | # dubious, but some code does it. We can't wait for it to be marked as done |
| 1565 | # normally - that won't happen until the interpreter is nearly dead. So |
| 1566 | # mark it done here. |
| 1567 | if _main_thread._os_thread_handle.is_done() and _is_main_interpreter(): |
| 1568 | # _shutdown() was already called |
| 1569 | return |
| 1570 | |
| 1571 | global _SHUTTING_DOWN |
| 1572 | _SHUTTING_DOWN = True |
| 1573 | |
| 1574 | # Call registered threading atexit functions before threads are joined. |
| 1575 | # Order is reversed, similar to atexit. |
| 1576 | for atexit_call in reversed(_threading_atexits): |
| 1577 | atexit_call() |
| 1578 | |
| 1579 | if _is_main_interpreter(): |
| 1580 | _main_thread._os_thread_handle._set_done() |
| 1581 | |
| 1582 | # Wait for all non-daemon threads to exit. |
| 1583 | _thread_shutdown() |
| 1584 | |
| 1585 | |
| 1586 | def main_thread(): |
nothing calls this directly
no test coverage detected