Understanding thread.join(timeout)

后端 未结 1 425
一个人的身影
一个人的身影 2020-12-19 05:07

So the timeout param, for a thread, should stop the thread after timeout seconds (if it hasn\'t terminated yet).

In my software I\

相关标签:
1条回答
  • 2020-12-19 05:28

    You're misunderstanding what timeout does. It just tells join how long to wait for the thread to stop. If the thread is still running after the timeout expires, the join call ends, but the thread keeps running.

    From the docs:

    When the timeout argument is present and not None, it should be a floating point number specifying a timeout for the operation in seconds (or fractions thereof). As join() always returns None, you must call isAlive() after join() to decide whether a timeout happened – if the thread is still alive, the join() call timed out.

    0 讨论(0)
提交回复
热议问题