add additional DB retry logic to the callback receiver

initially, I implemented this for _only_ the task worker, but it's
probably needed for callback event workers, too
This commit is contained in:
Ryan Petrello
2018-11-29 10:44:37 -05:00
parent 273d7a83f2
commit 0391dbc292
3 changed files with 6 additions and 9 deletions

View File

@@ -7,6 +7,7 @@ import signal
from uuid import UUID
from Queue import Empty as QueueEmpty
from django import db
from kombu import Producer
from kombu.mixins import ConsumerMixin
@@ -128,6 +129,10 @@ class BaseWorker(object):
logger.error("Exception on worker {}, restarting: ".format(idx) + str(e))
continue
try:
for conn in db.connections.all():
# If the database connection has a hiccup during the prior message, close it
# so we can establish a new connection
conn.close_if_unusable_or_obsolete()
self.perform_work(body, *args)
finally:
if 'uuid' in body: