I have a Flask-RESTful API (Python 3) and I'm trying to timeout a function call that runs a terminal command which executes a C++ program which may take a long time to complete. This function looks something like this:
def func(args):
...
result = subprocess.getoutput('./c_program')
...
I searched how to do this and I came across the following: Timeout on a function call I tried both of the suggested methods, but unfortunately neither work. Signal only works in the main thread (and I am in a threaded API), and multiprocessing doesn't stop I/O work. I kept looking but I only found mention of these two methods. Does anyone know any solution to this?