Below is a code snippet of what I am trying to achieve in python. I am trying to spawn a new thread on a target function from some other function. This new thread waits on the subprocess and exits. Now I want to kill this thread whenever a request comes in. This should also kill the corresponding subprocess that it was executing.
class ABC(object):
def process_thread(self):
#call a child process using subprocess.call()
def main(self):
t = threading.Thread(target=self.process_thread)
t.start()
obj = ABC()
obj.main()