As in the title, I've got a BaseThread running which i think doesnt die once process is finished.
The thread runs an ffmpeg call via subprocess.wait() (also tried communicate()). Everything seems to work but after closing cinema4d i cant reopen it, in the task manager there is a c4d process still there taking minimal resources. If i kill that task i can then reopen c4d again. My guess is im not using the threads correctly and the thread stays round after the process is finished.
My code below:
note: self.data is added to the thread elsewhere. Suppose I could add in init as well.
class CompileAVThread(c4d.threading.C4DThread):
def Main(self):
result = compile_av(**self.data)
if result is True:
gui.MessageDialog('Export completed')
path = os.path.dirname(self.data['output'])
open_path(path) # separate def that opens native os file browser at correct location
else:
print('Something went wrong')
gui.MessageDialog('Failed')
if self.TestBreak():
# Dont really get how TestBreak works..
print('Exiting thread please?')
return
And the subprocess:
p = subprocess.Popen(args=arg_list, shell=False)
if p.wait() == 0:
return True
else:
print "Failed - %s" % p.stdout.read()
return False