1
0
mirror of https://github.com/krateng/maloja.git synced 2023-08-10 21:12:55 +03:00

Added some log output and exception catching

This commit is contained in:
Krateng 2019-07-09 20:27:36 +02:00
parent 4323d0dc67
commit 40573ba4f7
2 changed files with 10 additions and 1 deletions

View File

@ -930,6 +930,7 @@ def sync():
# all entries by file collected
# so we don't open the same file for every entry
log("Syncing",module="debug")
entries = {}
for idx in range(len(SCROBBLES)):
@ -949,11 +950,15 @@ def sync():
SCROBBLES[idx] = (SCROBBLES[idx][0],SCROBBLES[idx][1],True)
log("Sorted into months",module="debug")
for e in entries:
tsv.add_entries("scrobbles/" + e + ".tsv",entries[e],comments=False)
#addEntries("scrobbles/" + e + ".tsv",entries[e],escape=False)
utilities.combineChecksums("scrobbles/" + e + ".tsv",cla.checksums)
log("Written files",module="debug")
global lastsync
lastsync = int(datetime.datetime.now(tz=datetime.timezone.utc).timestamp())

View File

@ -68,7 +68,11 @@ def customerror(error):
def graceful_exit(sig=None,frame=None):
#urllib.request.urlopen("http://[::1]:" + str(DATABASE_PORT) + "/sync")
database.sync()
log("Received signal to shutdown")
try:
database.sync()
except Exception as e:
log("Error while shutting down!",e)
log("Server shutting down...")
os._exit(42)