Skip to content

Commit

Permalink
added timer
Browse files Browse the repository at this point in the history
  • Loading branch information
xnetcat authored Oct 27, 2023
1 parent 2354929 commit 83a10b4
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion spotdl/console/entry_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""

import logging
import time
import signal
import sys

Expand Down Expand Up @@ -128,6 +129,8 @@ def graceful_exit(_signal, _frame):
signal.signal(signal.SIGINT, graceful_exit)
signal.signal(signal.SIGTERM, graceful_exit)

start_time = time.perf_counter()

try:
# Pick the operation to perform
# based on the name and run it!
Expand All @@ -136,12 +139,17 @@ def graceful_exit(_signal, _frame):
downloader=downloader,
)
except Exception:
downloader.progress_handler.close()
end_time = time.perf_counter()
logger.debug(f"Took {start_time - end_time} seconds")

downloader.progress_handler.close()
logger.exception("An error occurred")

sys.exit(1)

end_time = time.perf_counter()
logger.debug(f"Took {start_time - end_time} seconds")

if spotify_settings["use_cache_file"]:
save_spotify_cache(spotify_client.cache)

Expand Down

0 comments on commit 83a10b4

Please sign in to comment.