This commit is contained in:
parent
adc5c362eb
commit
67bc22963c
@ -78,14 +78,16 @@ def run_classification(task, target_class_name: str):
|
||||
|
||||
|
||||
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:
|
||||
message = uwsgi.mule_get_msg()
|
||||
task = json.loads(message)
|
||||
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',
|
||||
body=json.dumps(results).encode("utf-8"))
|
||||
|
||||
|
Reference in New Issue
Block a user