Skip to content
Snippets Groups Projects
Commit 113ff0e0 authored by Bo-Chun Chen's avatar Bo-Chun Chen
Browse files

Update default callback in rc_util

It acted like task manager when first design it.
Now we have proper task manager, update it.
The default behavior will be a caller waiting to complete msg
parent be439a15
No related branches found
No related tags found
No related merge requests found
......@@ -21,19 +21,18 @@ def add_account(username, email, full='', reason=''):
def worker(ch, method, properties, body):
msg = json.loads(body)
task = msg['task']
tasks[task] = msg['success']
print("Got msg: {}({})".format(msg['task'], msg['success']))
username = msg['username']
# Check if all tasks are done
done = True
for key, status in tasks.items():
if not status:
print("{} is not done yet.".format(key))
done = False
if done:
rc_rmq.stop_consume()
rc_rmq.delete_queue()
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_rmq.stop_consume()
rc_rmq.delete_queue()
def consume(username, routing_key='', callback=worker, debug=False):
if routing_key == '':
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment