made service less crashy
Some checks reported errors
continuous-integration/drone/push Build was killed
Some checks reported errors
continuous-integration/drone/push Build was killed
This commit is contained in:
parent
d17ab9d401
commit
ea968f9d18
@ -24,12 +24,19 @@ def message_callback(channel, method, properties, body):
|
||||
msg = json.loads(body.decode('utf-8'))
|
||||
except (UnicodeDecodeError, json.JSONDecodeError) as e:
|
||||
logging.warning(f"Invalid message recieved: {e}")
|
||||
channel.basic_ack(delivery_tag=method.delivery_tag) # We don't want this to be requeue
|
||||
return
|
||||
|
||||
scope.span.log_kv({'event': 'messageParsed', 'sampleTag': msg['tag']})
|
||||
|
||||
with opentracing.tracer.start_active_span('magicDoer.run_everything'):
|
||||
results = MagicDoer.run_everything(msg) # <- This is where the magic happens
|
||||
with opentracing.tracer.start_active_span('magicDoer.runEverything'):
|
||||
try:
|
||||
results = MagicDoer.run_everything(msg) # <- This is where the magic happens
|
||||
except Exception as e:
|
||||
logging.error(f"Something went wrong during AI run: {e}")
|
||||
logging.exception(e)
|
||||
channel.basic_nack(delivery_tag=method.delivery_tag, requeue=True)
|
||||
return
|
||||
|
||||
if results:
|
||||
channel.basic_publish(
|
||||
@ -37,7 +44,8 @@ def message_callback(channel, method, properties, body):
|
||||
routing_key='classification-result',
|
||||
body=json.dumps(results).encode("utf-8")
|
||||
)
|
||||
channel.basic_ack(delivery_tag=method.delivery_tag)
|
||||
|
||||
channel.basic_ack(delivery_tag=method.delivery_tag)
|
||||
|
||||
|
||||
def main():
|
||||
|
Loading…
Reference in New Issue
Block a user