What does sys.exit really do with multiple threads?

后端 未结 3 861
闹比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:31

    In your case, the end of the program is when the last thread will be terminated. Maybe kind of join() method(like in Java) in python will wait for other threads.

    Please, read this article(: there is a good explanation how to play with threads in your case Use of threading.Thread.join()

    and

    documentation https://docs.python.org/2/library/threading.html (but relax, it is only for additional knowledge.

    and read this article about daemon property(if you do not want to wait for others threads become terminated Meaning of daemon property on Python Threads

提交回复
热议问题