mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-06-07 20:28:38 +00:00
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
This commit is contained in:
parent
ed615887f0
commit
d08fd59434
@ -588,22 +588,26 @@ class FFmpegOpusAudio(FFmpegAudio):
|
|||||||
loop = asyncio.get_running_loop()
|
loop = asyncio.get_running_loop()
|
||||||
try:
|
try:
|
||||||
codec, bitrate = await loop.run_in_executor(None, lambda: probefunc(source, executable))
|
codec, bitrate = await loop.run_in_executor(None, lambda: probefunc(source, executable))
|
||||||
except Exception:
|
except (KeyboardInterrupt, SystemExit):
|
||||||
|
raise
|
||||||
|
except BaseException:
|
||||||
if not fallback:
|
if not fallback:
|
||||||
_log.exception("Probe '%s' using '%s' failed", method, executable)
|
_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)
|
_log.exception("Probe '%s' using '%s' failed, trying fallback", method, executable)
|
||||||
try:
|
try:
|
||||||
codec, bitrate = await loop.run_in_executor(None, lambda: fallback(source, executable))
|
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)
|
_log.exception("Fallback probe using '%s' failed", executable)
|
||||||
else:
|
else:
|
||||||
_log.debug("Fallback probe found codec=%s, bitrate=%s", codec, bitrate)
|
_log.debug("Fallback probe found codec=%s, bitrate=%s", codec, bitrate)
|
||||||
else:
|
else:
|
||||||
_log.debug("Probe found codec=%s, bitrate=%s", codec, bitrate)
|
_log.debug("Probe found codec=%s, bitrate=%s", codec, bitrate)
|
||||||
finally:
|
|
||||||
return codec, bitrate
|
return codec, bitrate
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _probe_codec_native(source, executable: str = 'ffmpeg') -> Tuple[Optional[str], Optional[int]]:
|
def _probe_codec_native(source, executable: str = 'ffmpeg') -> Tuple[Optional[str], Optional[int]]:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user