Newer
Older
Mitchell Moore
committed
from celery import Celery
import time
from flask_socketio import SocketIO
Ravi Tripathi
committed
import subprocess
Ravi Tripathi
committed
Mitchell Moore
committed
from gevent import monkey
monkey.patch_all(subprocess=True)
Ravi Tripathi
committed
celery = Celery('flask_user_reg', broker=broker_url)
Mitchell Moore
committed
socketio = SocketIO(message_queue=vars.message_queue)
Mitchell Moore
committed
Ravi Tripathi
committed
def send_msg(event, room):
print("Post '{}' to room '{}'".format(event,room))
socketio.emit(event, room=room)
Mitchell Moore
committed
Mitchell Moore
committed
@celery.task
def celery_create_account(user_data):
username = user_data.username
fullname = user_data.fullname
reason = user_data.reason
room = user_data.session
Mitchell Moore
committed
print(time.strftime("%m-%d-%Y_%H:%M:%S") + '\tUser ' + username + ' added to queue')
Ravi Tripathi
committed
send_msg('creating account', room)
print(username)
subprocess.call(["/opt/rabbitmq_agents/flask_producer.py", "ohpc_account_create", username])
Mitchell Moore
committed
print(time.strftime("%m-%d-%Y_%H:%M:%S") + '\tAccount successfully created for ' + username)
Ravi Tripathi
committed
send_msg('account ready', room)