【发布时间】:2017-08-20 21:43:20
【问题描述】:
我有一个包含“阻塞方法”的类。在该方法中,我正在听键来执行一些操作。有问题的操作是pkill。下面我贴一下:
def show_control(self, control):
"""docstring for control"""
if control == True:
from mkchromecast.getch import getch, pause
self.controls_msg()
try:
while(True):
key = getch()
if(key == 'p'):
if self.videoarg == True:
print('Pausing Casting Process...')
subprocess.call(['pkill', '-STOP', '-f', 'ffmpeg'])
...
原来ffmpeg进程暂停了,python脚本却被暂停了?我不明白为什么会这样。如果在常规脚本中创建相同的函数(不是在类中更清楚),则不会发生这种情况。我尝试使用 multithreading 和 multiprocessing 模块但没有成功。我究竟做错了什么?。谢谢。
【问题讨论】:
标签: python multithreading ffmpeg subprocess