timeout/stopping scipy curve_fit in a thread

450 views Asked by At

I have a GUI in which a python thread performs a scipy.curve_fit call. This can sometimes take a while and I would like to limit it to a certain time limit. If it takes longer than this I would like the thread to raise and error or return a default value.

I have searched around for different ways to do this. I can't make the thread regularly check for a timeout variable as when it starts running the curve_fit call it won't do anything else till it is finished.

Obviously this problem is not restricted to the curve_fit function but any library function that could take a long time to return, which I put in a thread.

Is this the best way to kill the thread?: Is there any way to kill a Thread in Python?

Is there a better more Pythonic way of doing this that I am missing?

Thank you for your help.

0

There are 0 answers