[rt2fs] retry on failed ticket dump
This commit is contained in:
parent
fb7c1f7582
commit
fd401545ca
1 changed files with 31 additions and 26 deletions
7
rt2fs
7
rt2fs
|
@ -52,8 +52,9 @@ os.makedirs("attachments", exist_ok=True)
|
||||||
|
|
||||||
ticket_ids = range(config["rt_start"], config["rt_end"])
|
ticket_ids = range(config["rt_start"], config["rt_end"])
|
||||||
|
|
||||||
def dump(id):
|
def dump(id, retries=3):
|
||||||
print(f"Dumping RT#{id}")
|
print(f"Dumping RT#{id}")
|
||||||
|
try:
|
||||||
ticket_dumpfile = f"tickets/{id}"
|
ticket_dumpfile = f"tickets/{id}"
|
||||||
if not os.path.exists(ticket_dumpfile):
|
if not os.path.exists(ticket_dumpfile):
|
||||||
ticket = rt.get_ticket(id)
|
ticket = rt.get_ticket(id)
|
||||||
|
@ -80,6 +81,10 @@ def dump(id):
|
||||||
data = {"ticket": ticket, "history": history}
|
data = {"ticket": ticket, "history": history}
|
||||||
with open(ticket_dumpfile, "wb") as handle:
|
with open(ticket_dumpfile, "wb") as handle:
|
||||||
pickle.dump(data, 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
|
worker_count = 4
|
||||||
with Pool(worker_count) as p:
|
with Pool(worker_count) as p:
|
||||||
|
|
Loading…
Reference in a new issue