CPython internal: register *func* to be called before joining threads. The registered *func* is called with its arguments just before all non-daemon threads are joined in `_shutdown()`. It provides a similar purpose to `atexit.register()`, but its functions are called prior to
(func, *arg, **kwargs)
| 1514 | _SHUTTING_DOWN = False |
| 1515 | |
| 1516 | def _register_atexit(func, *arg, **kwargs): |
| 1517 | """CPython internal: register *func* to be called before joining threads. |
| 1518 | |
| 1519 | The registered *func* is called with its arguments just before all |
| 1520 | non-daemon threads are joined in `_shutdown()`. It provides a similar |
| 1521 | purpose to `atexit.register()`, but its functions are called prior to |
| 1522 | threading shutdown instead of interpreter shutdown. |
| 1523 | |
| 1524 | For similarity to atexit, the registered functions are called in reverse. |
| 1525 | """ |
| 1526 | if _SHUTTING_DOWN: |
| 1527 | raise RuntimeError("can't register atexit after shutdown") |
| 1528 | |
| 1529 | call = functools.partial(func, *arg, **kwargs) |
| 1530 | _threading_atexits.append(call) |
| 1531 | |
| 1532 | |
| 1533 | from _thread import stack_size |