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:
		| @@ -24,12 +24,19 @@ def message_callback(channel, method, properties, body): | |||||||
|             msg = json.loads(body.decode('utf-8')) |             msg = json.loads(body.decode('utf-8')) | ||||||
|         except (UnicodeDecodeError, json.JSONDecodeError) as e: |         except (UnicodeDecodeError, json.JSONDecodeError) as e: | ||||||
|             logging.warning(f"Invalid message recieved: {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 |             return | ||||||
|  |  | ||||||
|         scope.span.log_kv({'event': 'messageParsed', 'sampleTag': msg['tag']}) |         scope.span.log_kv({'event': 'messageParsed', 'sampleTag': msg['tag']}) | ||||||
|  |  | ||||||
|         with opentracing.tracer.start_active_span('magicDoer.run_everything'): |         with opentracing.tracer.start_active_span('magicDoer.runEverything'): | ||||||
|  |             try: | ||||||
|                 results = MagicDoer.run_everything(msg)  # <- This is where the magic happens |                 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: |         if results: | ||||||
|             channel.basic_publish( |             channel.basic_publish( | ||||||
| @@ -37,6 +44,7 @@ def message_callback(channel, method, properties, body): | |||||||
|                 routing_key='classification-result', |                 routing_key='classification-result', | ||||||
|                 body=json.dumps(results).encode("utf-8") |                 body=json.dumps(results).encode("utf-8") | ||||||
|             ) |             ) | ||||||
|  |  | ||||||
|         channel.basic_ack(delivery_tag=method.delivery_tag) |         channel.basic_ack(delivery_tag=method.delivery_tag) | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user