Skip to content

Commit

Permalink
Fix for null values in instrument and instrument size
Browse files Browse the repository at this point in the history
Guard against this so the listener can gracefully continue after encountering any weird data
  • Loading branch information
mgdaily committed Jan 29, 2024
1 parent 53f4ecb commit 66bbe89
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions banzai/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,13 @@ def get_consumers(self, Consumer, channel):

def on_message(self, body, message):
instrument = LCOFrameFactory.get_instrument_from_header(body, self.runtime_context.db_address)
if instrument is None or instrument.nx is None:
queue_name = self.runtime_context.CELERY_TASK_QUEUE_NAME
elif instrument.nx * instrument.ny > self.runtime_context.LARGE_WORKER_THRESHOLD:
queue_name = self.runtime_context.LARGE_WORKER_QUEUE
else:
queue_name = self.runtime_context.CELERY_TASK_QUEUE_NAME
queue_name = self.runtime_context.CELERY_TASK_QUEUE_NAME
try:
if instrument.nx * instrument.ny > self.runtime_context.LARGE_WORKER_THRESHOLD:
queue_name = self.runtime_context.LARGE_WORKER_QUEUE
except Exception as e:
logger.warning(f"Instrument not found in DB, or instrument size not defined: {e}", extra_tags={'instrument': body.get('INSTRUME')})

process_image.apply_async(args=(body, vars(self.runtime_context)),
queue=queue_name)
message.ack() # acknowledge to the sender we got this message (it can be popped)
Expand Down

0 comments on commit 66bbe89

Please sign in to comment.