What does sys.exit really do with multiple threads?

后端 未结 3 865
闹比i
闹比i 2020-11-28 16:06

I was really confused by sys.exit() in python. In python documentation, it says \"Exit from Python\"; does that mean when sys.exit() is called in a python progr

3条回答
  •  醉话见心
    2020-11-28 16:17

    As per the documentation sys.exit() raises SystemExit:

    Exit the interpreter by raising SystemExit(status).

    If SystemExit reaches the default exception handler, it calls handle_system_exit(), which more or less pushes through to Py_Finalize(), which in turn calls wait_for_thread_shutdown() in Python 2, so sys.exit() is the same as the normal falling off the bottom of the main module in waiting for all non-daemon threads to terminate.

提交回复
热议问题