mirror of
https://github.com/spl0k/supysonic.git
synced 2024-11-13 21:52:18 +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:
|
try:
|
||||||
return binascii.unhexlify(password[4:].encode("utf-8")).decode("utf-8")
|
return binascii.unhexlify(password[4:].encode("utf-8")).decode("utf-8")
|
||||||
except:
|
except ValueError:
|
||||||
return password
|
return password
|
||||||
|
|
||||||
|
|
||||||
|
@ -164,7 +164,8 @@ def stream_media():
|
|||||||
if not data:
|
if not data:
|
||||||
break
|
break
|
||||||
yield data
|
yield data
|
||||||
except: # pragma: nocover
|
except BaseException:
|
||||||
|
# Make sure child processes are always killed
|
||||||
if dec_proc != None:
|
if dec_proc != None:
|
||||||
dec_proc.kill()
|
dec_proc.kill()
|
||||||
proc.kill()
|
proc.kill()
|
||||||
|
@ -159,9 +159,10 @@ class Cache(object):
|
|||||||
self._make_space(size, key=key)
|
self._make_space(size, key=key)
|
||||||
os.replace(f.name, self._filepath(key))
|
os.replace(f.name, self._filepath(key))
|
||||||
self._record_file(key, size)
|
self._record_file(key, size)
|
||||||
except:
|
except Exception:
|
||||||
f.close()
|
f.close()
|
||||||
os.remove(f.name)
|
with contextlib.suppress(OSError):
|
||||||
|
os.remove(f.name)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def set(self, key, value):
|
def set(self, key, value):
|
||||||
|
@ -157,6 +157,6 @@ class Jukebox(object):
|
|||||||
logger.debug("Start playing with command %s", args)
|
logger.debug("Start playing with command %s", args)
|
||||||
try:
|
try:
|
||||||
return Popen(args, stdin=DEVNULL, stdout=DEVNULL, stderr=DEVNULL)
|
return Popen(args, stdin=DEVNULL, stdout=DEVNULL, stderr=DEVNULL)
|
||||||
except:
|
except Exception:
|
||||||
logger.exception("Failed running play command")
|
logger.exception("Failed to run play command")
|
||||||
return None
|
return None
|
||||||
|
@ -5,7 +5,7 @@ import uuid
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
bytes = buffer
|
bytes = buffer
|
||||||
except:
|
except NameError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
|
@ -5,7 +5,7 @@ import uuid
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
bytes = buffer
|
bytes = buffer
|
||||||
except:
|
except NameError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
|
Loading…
Reference in New Issue
Block a user