Python , Timeout on a function on child thread without using signal and thread.join

心已入冬 提交于 2019-12-11 05:03:29

问题


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

来源:https://stackoverflow.com/questions/14646431/python-timeout-on-a-function-on-child-thread-without-using-signal-and-thread-j

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!