Skip to content

Commit

Permalink
Pgn error catching (#1034)
Browse files Browse the repository at this point in the history
* Catch PGN writing error so queue doesn't stop

* Make sure task_done() is called consistently

* Delete extra task_done() call
  • Loading branch information
MarkZH authored Oct 13, 2024
1 parent f59b5d7 commit c0ae365
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/lichess_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,18 @@ def do_correspondence_ping(control_queue: CONTROL_QUEUE_TYPE, period: datetime.t
def write_pgn_records(pgn_queue: PGN_QUEUE_TYPE, config: Configuration, username: str) -> None:
"""Write PGN records to files as games finish."""
while True:
mark_task_done = False
try:
event = pgn_queue.get()
mark_task_done = True
save_pgn_record(event, config, username)
pgn_queue.task_done()
except InterruptedError:
pass
except Exception:
logger.exception("Could not write PGN to file")

if mark_task_done:
pgn_queue.task_done()


def handle_old_logs(auto_log_filename: str) -> None:
Expand Down

0 comments on commit c0ae365

Please sign in to comment.