Skip to content

Commit

Permalink
Worker: Restart frequency protection also when no exception raised
Browse files Browse the repository at this point in the history
  • Loading branch information
ask committed Jun 14, 2016
1 parent 1f4813e commit 323b66f
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions celery/worker/consumer/consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,14 @@ def _limit_task(self, request, bucket, tokens):
def start(self):
blueprint = self.blueprint
while blueprint.state != CLOSE:
self.restart_count += 1
maybe_shutdown()
if self.restart_count:
try:
self._restart_state.step()
except RestartFreqExceeded as exc:
crit('Frequent restarts detected: %r', exc, exc_info=1)
sleep(1)
self.restart_count += 1
try:
blueprint.start(self)
except self.connection_errors as exc:
Expand All @@ -314,11 +320,6 @@ def start(self):
if isinstance(exc, OSError) and exc.errno == errno.EMFILE:
raise # Too many open files
maybe_shutdown()
try:
self._restart_state.step()
except RestartFreqExceeded as exc:
crit('Frequent restarts detected: %r', exc, exc_info=1)
sleep(1)
if blueprint.state != CLOSE:
if self.connection:
self.on_connection_error_after_connected(exc)
Expand Down

0 comments on commit 323b66f

Please sign in to comment.