Skip to content

Commit

Permalink
Fix for crasher in runmailer_pg
Browse files Browse the repository at this point in the history
  • Loading branch information
spookylukey committed Dec 28, 2023
1 parent 863a997 commit 77a6542
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Change log
==========

2.3.1 - unreleased
------------------

* Fixed rare crasher in runmailer_pg when notifications list is empty.

2.3 - 2023-09-25
----------------

Expand Down
9 changes: 8 additions & 1 deletion src/mailer/postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,14 @@ def postgres_send_loop():
pass
else:
conn.poll()
last = conn.notifies.pop()
try:
last = conn.notifies.pop()
except IndexError:
# Not entirely sure how this happens, but it could only happen
# if `notifies` is empty, because there are no more notifications
# to process.
continue

# We don't care about payload or how many NOTIFY there were,
# we'll just run once, so drop the rest:
to_drop = conn.notifies
Expand Down

0 comments on commit 77a6542

Please sign in to comment.