This commit is contained in:
parent
adc5c362eb
commit
67bc22963c
@ -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"))
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user