栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

在Windows中处理子进程崩溃

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

在Windows中处理子进程崩溃

经过更多的谷歌搜索后,我偶然发现了这个 http://www.activestate.com/blog/2007/11/supressing-
windows-error-report-messagebox-subprocess-and-
ctypes

它需要一些修补,但是下面的方法现在不会出现令人讨厌的Windows消息:)注意subprocess.Popen中的creationflags =subprocess_flags

def convert_mp3_to_wav(input_filename, output_filename):    if sys.platform.startswith("win"):        # Don't display the Windows GPF dialog if the invoked program dies.        # See comp.os.ms-windows.programmer.win32        # How to suppress crash notification dialog?, Jan 14,2004 -        # Raymond Chen's response [1]        import ctypes        SEM_NOGPFAULTERRORBOX = 0x0002 # From MSDN        ctypes.windll.kernel32.SetErrorMode(SEM_NOGPFAULTERRORBOX);        subprocess_flags = 0x8000000 #win32con.CREATE_NO_WINDOW?    else:        subprocess_flags = 0    """    converts the incoming mp3 file to wave file    """    if not os.path.exists(input_filename):        raise AudioProcessingException, "file %s does not exist" % input_filename    #exec("lame {$tmpname}_o.mp3 -f {$tmpname}.mp3 && lame --depre {$tmpname}.mp3 {$tmpname}.wav");    command = ["lame", "--silent", "--depre", input_filename, output_filename]    process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, creationflags=subprocess_flags)    (stdout, stderr) = process.communicate()    if process.returnpre != 0 or not os.path.exists(output_filename):        raise AudioProcessingException, stdout    return output_filename


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/516752.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号