mirror of
https://github.com/spl0k/supysonic.git
synced 2024-12-22 08:56:17 +00:00
Fix exception handling
Bare excepts will catch `GeneratorExit` exceptions which are raised whenever a generator stops. This was causing issues when transcoding and caching the results. All instances of bare excepts have been replaced with scoped versions.
This commit is contained in:
parent
d6c00e0f3d
commit
bc6e768627
@ -41,7 +41,7 @@ def decode_password(password):
|
||||
|
||||
try:
|
||||
return binascii.unhexlify(password[4:].encode("utf-8")).decode("utf-8")
|
||||
except:
|
||||
except ValueError:
|
||||
return password
|
||||
|
||||
|
||||
|
@ -164,7 +164,8 @@ def stream_media():
|
||||
if not data:
|
||||
break
|
||||
yield data
|
||||
except: # pragma: nocover
|
||||
except BaseException:
|
||||
# Make sure child processes are always killed
|
||||
if dec_proc != None:
|
||||
dec_proc.kill()
|
||||
proc.kill()
|
||||
|
@ -159,9 +159,10 @@ class Cache(object):
|
||||
self._make_space(size, key=key)
|
||||
os.replace(f.name, self._filepath(key))
|
||||
self._record_file(key, size)
|
||||
except:
|
||||
except Exception:
|
||||
f.close()
|
||||
os.remove(f.name)
|
||||
with contextlib.suppress(OSError):
|
||||
os.remove(f.name)
|
||||
raise
|
||||
|
||||
def set(self, key, value):
|
||||
|
@ -157,6 +157,6 @@ class Jukebox(object):
|
||||
logger.debug("Start playing with command %s", args)
|
||||
try:
|
||||
return Popen(args, stdin=DEVNULL, stdout=DEVNULL, stderr=DEVNULL)
|
||||
except:
|
||||
logger.exception("Failed running play command")
|
||||
except Exception:
|
||||
logger.exception("Failed to run play command")
|
||||
return None
|
||||
|
@ -5,7 +5,7 @@ import uuid
|
||||
|
||||
try:
|
||||
bytes = buffer
|
||||
except:
|
||||
except NameError:
|
||||
pass
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
|
@ -5,7 +5,7 @@ import uuid
|
||||
|
||||
try:
|
||||
bytes = buffer
|
||||
except:
|
||||
except NameError:
|
||||
pass
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
|
Loading…
Reference in New Issue
Block a user