Python , Timeout on a function on child thread wit

2019-07-24 04:20发布

问题:

I want to add a timeout on one function which is getting called inside a child thread. I can't use a signal, as a signal should be on the main thread. I can't use thread.join(time_out), as that function can sometimes be executed in a few seconds, and in those cases the thread will always wait out the time_out.

Are there any other approaches?

Sources:

  • thread.join: Timeout function using threading in python does not work
  • signal: Timeout function if it takes too long to finish