提问人:Mohamed Darwesh 提问时间:3/9/2023 最后编辑:Mohamed Darwesh 更新时间:3/9/2023 访问量:32
检查子进程是否被用户终止
Checking if subprocess was terminated by user
问:
# Create a new terminal window and run the ffmpeg command in it
cmd = ' '.join(ffmpeg.compile(output_stream, overwrite_output=True))
compressing = subprocess.Popen('start cmd /k {}'.format(cmd), shell=True)
while compressing.poll() is None: #check if the process is still running
print('Processing video...')
break
else:
if compressing.returncode == 0: #check if the process was canceled by the user
print('Video processing canceled by user!')
else: #if the process was completed successfully
print('Video processing complete!')
我想检查进程(终端)是否被用户关闭,它应该打印该句子,但是即使用户杀死了子进程终端,它也总是卡住了"Processing Video"
答: 暂无答案
评论
break
cmd
start
start
cmd
list(ffmpeg.compile(...))