Skip to content

Commit

Permalink
Remove recusive calls to queue declare
Browse files Browse the repository at this point in the history
  • Loading branch information
nathandf committed Jan 8, 2024
1 parent 095e529 commit c832e31
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/engine/src/core/Server.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,18 +321,13 @@ def _deregister_worker(self, worker, terminated=False):
def _get_active_workers(self, key):
return [worker for worker in self.active_workers if worker.key == key]

def _declare_queue(self, channel, queue, exclusive=True, retry_count=0, max_retries=25):
max_retries = 25
def _declare_queue(self, channel, queue, exclusive=True):
try:
logger.info(f"{lbuf('[SERVER]')} Declaring Queue '{queue}' | Attempts ({retry_count})")
return channel.queue_declare(queue=queue, exclusive=exclusive)
except ChannelClosedByBroker as e:
time.sleep(CONNECTION_RETRY_DELAY)
if retry_count >= max_retries:
logger.critical(f"{lbuf('[SERVER]')} Exclusive Queue Declaration Error: Maximum retry attempts reached ({MAX_CONNECTION_ATTEMPTS}) for queue {queue} | {e}")
sys.exit(1)
retry_count+=1
self._declare_queue(channel, queue, exclusive=exclusive, retry_count=retry_count)
logger.critical(f"{lbuf('[SERVER]')} Exclusive queue declaration error for queue '{queue}' | {e}")
sys.exit(1)


def _resolve_idempotency_key(self, request):
# Check the context's meta for an idempotency key. This will be used
Expand Down

0 comments on commit c832e31

Please sign in to comment.