From 1111246cc4d3daa6929e66e7380ba60114cf6d6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abdulkadir=20Furkan=20=C5=9Eanl=C4=B1?= Date: Wed, 17 Nov 2021 11:31:17 +0100 Subject: [PATCH] Print more informtion, implement increasing sleep on failure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Abdulkadir Furkan Şanlı --- lb_import.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lb_import.py b/lb_import.py index 09f6f15..75d57b8 100755 --- a/lb_import.py +++ b/lb_import.py @@ -47,19 +47,24 @@ def main(): client = connect_client(sys.argv[1]) with open(sys.argv[2], 'r') as read_file: exported = json.load(read_file) - print("Opened file, starting import...") + print("Opened file with {} listens, starting import...".format(len(exported))) + imported = 0 for raw_listen in exported: listen = parse_listen(raw_listen) for x in range(0, 5): try: client.submit_single_listen(listen) + imported = imported + 1 + print("Imported {} listens.".format(imported), end='\r') submit_error = None except BaseException: submit_error = True if submit_error: - print("Error occurred, retrying in 5 seconds...") - sleep(5) + sleep_time = x * 5 + print( + "\nError occurred, retrying in {} seconds...".format(sleep_time)) + sleep(sleep_time) else: break