We have a function that opens a file (file is custom .oxr file). Issue is that sometimes the file is corrupted and the program halts and does not proceed and come out of the function.Hence the entire program is affected.
I am trying to develop a method that will time out the function after certain seconds. I have implemented this using threading. Here is the concept:- I am calling the function as a thread by using 'thread.join' method that waits for certain seconds for threaded function to execute. After timeout, I am just aborting the thread. So, the call returns back to code after the point where thread was called. It works as expected!
Is this concept good practice?