Skip to content

Commit

Permalink
Reprocess failed files
Browse files Browse the repository at this point in the history
  • Loading branch information
greg-finley committed Aug 29, 2024
1 parent ecefaa1 commit ceb027e
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions queue_files/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,27 @@ def run(event, context):
except Exception as err:
print(f"Failed to delete {clean_name}: {err}")

# also reenque all failed files
with conn.cursor() as cursor:
cursor.execute(
"""
SELECT id, desktop_path
FROM dropbox
WHERE status = 'failed'
FOR UPDATE SKIP LOCKED
"""
)
failed_entries = cursor.fetchall()

if failed_entries:
for entry_id, clean_name in failed_entries:
future = publisher.publish(TOPIC_NAME, clean_name.encode("utf-8"))
futures.append(future)
cursor.execute(
"UPDATE dropbox SET status = 'pending' WHERE id = %s", (entry_id,)
)
print(f"Re-queued {clean_name}")

for future in futures:
future.result()

Expand Down

0 comments on commit ceb027e

Please sign in to comment.