Browse Source

Avoid returning in finally

Specifically reraise KeyboardInterrupt, SystemExit
Swallow other BaseExceptions due to the way the standard library uses
them and the intent of this function
pull/9994/head
Michael H 5 months ago
committed by GitHub
parent
commit
d08fd59434
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 14
      discord/player.py

14
discord/player.py

@ -588,22 +588,26 @@ class FFmpegOpusAudio(FFmpegAudio):
loop = asyncio.get_running_loop()
try:
codec, bitrate = await loop.run_in_executor(None, lambda: probefunc(source, executable))
except Exception:
except (KeyboardInterrupt, SystemExit):
raise
except BaseException:
if not fallback:
_log.exception("Probe '%s' using '%s' failed", method, executable)
return # type: ignore
return None, None
_log.exception("Probe '%s' using '%s' failed, trying fallback", method, executable)
try:
codec, bitrate = await loop.run_in_executor(None, lambda: fallback(source, executable))
except Exception:
except (KeyboardInterrupt, SystemExit):
raise
except BaseException:
_log.exception("Fallback probe using '%s' failed", executable)
else:
_log.debug("Fallback probe found codec=%s, bitrate=%s", codec, bitrate)
else:
_log.debug("Probe found codec=%s, bitrate=%s", codec, bitrate)
finally:
return codec, bitrate
return codec, bitrate
@staticmethod
def _probe_codec_native(source, executable: str = 'ffmpeg') -> Tuple[Optional[str], Optional[int]]:

Loading…
Cancel
Save