diff --git a/anki/sound.py b/anki/sound.py index 8dc2223b5b2..147fe606cc6 100644 --- a/anki/sound.py +++ b/anki/sound.py @@ -149,16 +149,20 @@ def cleanupOldMplayerProcesses(): exeDir = os.path.dirname(os.path.abspath(sys.argv[0])) - for proc in psutil.process_iter(attrs=['pid', 'name', 'exe']): - if not proc.info['exe'] or proc.info['name'] != 'mplayer.exe': - continue + for proc in psutil.process_iter(): + try: + info = proc.as_dict(attrs=['pid', 'name', 'exe']) + if not info['exe'] or info['name'] != 'mplayer.exe': + continue - # not anki's bundled mplayer - if os.path.dirname(proc.info['exe']) != exeDir: - continue + # not anki's bundled mplayer + if os.path.dirname(info['exe']) != exeDir: + continue - print("terminating old mplayer process...") - proc.kill() + print("terminating old mplayer process...") + proc.kill() + except SystemError: + pass mplayerCmd = ["mplayer", "-really-quiet", "-noautosub"] if isWin: