Poll up to 3 minutes for delivery confirmation after sending
Checks every 15s instead of once. Catches COMPLETED/FAILURE in the same run so the counter and ntfy are accurate. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
a05d49632b
commit
c66bd57bdc
1 changed files with 14 additions and 8 deletions
22
autofax.py
22
autofax.py
|
|
@ -270,14 +270,20 @@ def main():
|
|||
result = send_fax(pdf_path)
|
||||
entries.append(result)
|
||||
|
||||
# Wait briefly and check initial status
|
||||
if result["fax_id"] and result["status"] == "QUEUED":
|
||||
time.sleep(15)
|
||||
status_data = check_fax_status(result["fax_id"])
|
||||
if status_data:
|
||||
result["status"] = status_data.get("status", result["status"])
|
||||
if result["status"] == "FAILURE":
|
||||
result["failure_reason"] = status_data.get("failureReason", "Unknown")
|
||||
# Poll until final status (up to 3 minutes)
|
||||
if result["fax_id"] and result["status"] in ("QUEUED", "IN_PROGRESS"):
|
||||
print("Waiting for delivery confirmation...", end="", flush=True)
|
||||
for _ in range(12):
|
||||
time.sleep(15)
|
||||
print(".", end="", flush=True)
|
||||
status_data = check_fax_status(result["fax_id"])
|
||||
if status_data:
|
||||
result["status"] = status_data.get("status", result["status"])
|
||||
if result["status"] == "FAILURE":
|
||||
result["failure_reason"] = status_data.get("failureReason", "Unknown")
|
||||
if result["status"] in ("COMPLETED", "FAILURE"):
|
||||
break
|
||||
print()
|
||||
|
||||
save_log(entries)
|
||||
report_path = generate_report(entries)
|
||||
|
|
|
|||
Loading…
Reference in a new issue