Print more informtion, implement increasing sleep on failure
Signed-off-by: Abdulkadir Furkan Şanlı <me@abdulocra.cy>
This commit is contained in:
parent
a4e56f7a9e
commit
1111246cc4
11
lb_import.py
11
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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user