notify for redis storage errors
This commit is contained in:
parent
9e6feb90a5
commit
be807ae2c0
@ -108,7 +108,8 @@ class RedisCache:
|
|||||||
Returns:
|
Returns:
|
||||||
None
|
None
|
||||||
"""
|
"""
|
||||||
redis_mapping = {
|
try:
|
||||||
|
redis_mapping = {
|
||||||
'id': sqlite_id,
|
'id': sqlite_id,
|
||||||
'src': lyr_result.src,
|
'src': lyr_result.src,
|
||||||
'date_retrieved': time.time(),
|
'date_retrieved': time.time(),
|
||||||
@ -120,15 +121,16 @@ class RedisCache:
|
|||||||
'tags': '(none)',
|
'tags': '(none)',
|
||||||
'liked': 0,
|
'liked': 0,
|
||||||
}
|
}
|
||||||
newkey = f"lyrics:000{sqlite_id}"
|
newkey = f"lyrics:000{sqlite_id}"
|
||||||
jsonset = await self.redis_client.json().set(newkey, Path.root_path(),
|
jsonset = await self.redis_client.json().set(newkey, Path.root_path(),
|
||||||
redis_mapping)
|
redis_mapping)
|
||||||
if not jsonset:
|
if not jsonset:
|
||||||
raise RedisException(f"Failed to store {lyr_result.artist} - {lyr_result.song} (SQLite id: {sqlite_id}):\n{jsonset}")
|
raise RedisException(f"Failed to store {lyr_result.artist} - {lyr_result.song} (SQLite id: {sqlite_id}):\n{jsonset}")
|
||||||
logging.info("Stored %s - %s (related SQLite Row ID: %s) to %s",
|
logging.info("Stored %s - %s (related SQLite Row ID: %s) to %s",
|
||||||
lyr_result.artist, lyr_result.song, sqlite_id, newkey)
|
lyr_result.artist, lyr_result.song, sqlite_id, newkey)
|
||||||
await self.notifier.send("INFO",
|
await self.notifier.send("INFO",
|
||||||
f"Stored {lyr_result.artist} - {lyr_result.song} (related SQLite Row ID: {sqlite_id}) to {newkey}")
|
f"Stored {lyr_result.artist} - {lyr_result.song} (related SQLite Row ID: {sqlite_id}) to {newkey}")
|
||||||
|
except Exception as e:
|
||||||
|
await self.notifier.send(f"ERROR @ {__file__}",
|
||||||
|
f"Failed to store {lyr_result.artist} - {lyr_result.song}\
|
||||||
|
(SQLite id: {sqlite_id}) to Redis:\n{str(e)}")
|
Loading…
x
Reference in New Issue
Block a user