mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-06-07 04:17:16 +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()
|
||||
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…
x
Reference in New Issue
Block a user