I am facing a problem to kill a spawned subprocess from a different thread on program exit. I have even tried atexit.register but no help. Please see me as new to python. Please see my code below
bgp = BigGrapePines()
bs = BigSourers()
    def run():
        proc = subprocess.Popen("java MyAppPerformStunts", stdout=outfile, stderr=subprocess.STDOUT,
                                                cwd=self.workingdirectory, shell=True)   
        proc.wait()
        return proc 
#----------------------------
    def callfunc(a,b):
        procobj = bs.run() #Going to take hrs to complete
        print("Process PID is given below")
        print(procobj.pid)
        bgp.setppid(procobj.pid)
    def cleanup():
        prid = bgp.getppid()
        if prid is None:
            pass
        else:
            try:
                os.kill(prid,signal.SIGTERM)
            except OSError:
                print("Cannot Kill the Process" + str(prid))
        pass
    def main(): 
        thread = Thread(target = callfunc, args = ("Latest","1"))
        thread.daemon = True
        thread.start()
        time.sleep(20)
        performoperations();
        cleanup()
if __name__ == "__main__":
    main()      
performoperations() will run for  few minutes. On completing main thread, I want to kill my subprocess which opened on run(). Since I am getting the pid as the return value of run(), I am not able  to proceed further
    Any help will be hihgly appreciated 
