4
0

Pikachu hotficc
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Pünkösd Marcell 2020-06-20 20:57:23 +02:00
parent adc5c362eb
commit 67bc22963c

View File

@ -78,14 +78,16 @@ def run_classification(task, target_class_name: str):
def main(): def main():
connection = pika.BlockingConnection(pika.connection.URLParameters(os.environ['PIKA_URL']))
channel = connection.channel()
channel.exchange_declare(exchange=os.environ['PIKA_EXCHANGE'], exchange_type='fanout')
while True: while True:
message = uwsgi.mule_get_msg() message = uwsgi.mule_get_msg()
task = json.loads(message) task = json.loads(message)
results = run_classification(task, os.environ['TARGET_CLASS_NAME']) results = run_classification(task, os.environ['TARGET_CLASS_NAME'])
# For some reason Pika loves to disconnect randomly...
connection = pika.BlockingConnection(pika.connection.URLParameters(os.environ['PIKA_URL']))
channel = connection.channel()
channel.exchange_declare(exchange=os.environ['PIKA_EXCHANGE'], exchange_type='fanout')
channel.basic_publish(exchange=os.environ['PIKA_EXCHANGE'], routing_key='classification-result', channel.basic_publish(exchange=os.environ['PIKA_EXCHANGE'], routing_key='classification-result',
body=json.dumps(results).encode("utf-8")) body=json.dumps(results).encode("utf-8"))