Commit ff4505b0 authored by Krish Moodbidri's avatar Krish Moodbidri
Browse files

added callback function with error print to command line

parent c95fc667
...@@ -4,6 +4,7 @@ from flask_socketio import SocketIO ...@@ -4,6 +4,7 @@ from flask_socketio import SocketIO
import subprocess import subprocess
import vars import vars
import sys import sys
import json
sys.path.append('/cm/shared/rabbitmq_agents/') sys.path.append('/cm/shared/rabbitmq_agents/')
import rc_util import rc_util
...@@ -16,7 +17,18 @@ celery = Celery('flask_user_reg', broker=broker_url) ...@@ -16,7 +17,18 @@ celery = Celery('flask_user_reg', broker=broker_url)
socketio = SocketIO(message_queue=vars.message_queue) socketio = SocketIO(message_queue=vars.message_queue)
def callback(): def callback(channel, method, properties, body):
msg = json.loads(body)
username = msg['username']
if msg['success']:
print(f'Account for {username} has been created.')
else:
print(f"There's some issue while creating account for {username}")
errmsg = msg.get('errmsg', [])
for err in errmsg:
print(err)
rc_util.rc_rmq.stop_consume() rc_util.rc_rmq.stop_consume()
rc_util.rc_rmq.delete_queue() rc_util.rc_rmq.delete_queue()
...@@ -39,4 +51,5 @@ def celery_create_account(json, session): ...@@ -39,4 +51,5 @@ def celery_create_account(json, session):
rc_util.add_account(username, email, fullname, reason) rc_util.add_account(username, email, fullname, reason)
print('sent account info') print('sent account info')
print('Waiting for completion...') print('Waiting for completion...')
rc_util.consume(username, routing_key=f'complete.{username}', callback=callback) rc_util.consume(username, routing_key=f'complete.{username}', callback=callback)
send_msg('account ready', room)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment