[rt2fs] retry on failed ticket dump

This commit is contained in:
fnux 2024-04-22 11:52:28 +02:00
parent fb7c1f7582
commit fd401545ca
No known key found for this signature in database
GPG key ID: 4502C902C00A1E12

7
rt2fs
View file

@ -52,8 +52,9 @@ os.makedirs("attachments", exist_ok=True)
ticket_ids = range(config["rt_start"], config["rt_end"])
def dump(id):
def dump(id, retries=3):
print(f"Dumping RT#{id}")
try:
ticket_dumpfile = f"tickets/{id}"
if not os.path.exists(ticket_dumpfile):
ticket = rt.get_ticket(id)
@ -80,6 +81,10 @@ def dump(id):
data = {"ticket": ticket, "history": history}
with open(ticket_dumpfile, "wb") as handle:
pickle.dump(data, handle)
except:
print(f"Failed to dump RT#{id}.. ({retries} retries left)")
if retries > 0:
dump(id, retries - 1)
worker_count = 4
with Pool(worker_count) as p: