Skip to content
Snippets Groups Projects
Commit 3adc9f39 authored by Mitchell Moore's avatar Mitchell Moore
Browse files

Begin celery implementation and call

parent aed43b96
No related branches found
No related tags found
1 merge request!35Version 1b openstack rabbitmq
......@@ -3,8 +3,9 @@
import os
import time
import signal
import tasks
import pika
from flask import session
from flask_socketio import SocketIO, join_room
......@@ -55,7 +56,8 @@ def request_account(json, methods=['GET', 'POST']):
print (time.strftime("%m-%d-%Y_%H:%M:%S") + '\tQueue request received: ' + str(json))
try:
create_account(json['username'], json['fullname'], json['reason'])
# create_account(json['username'], json['fullname'], json['reason'])
tasks.celery_create_account(json['username'], json['fullname'], json['reason'], room_global)
except Exception as e:
print(time.strftime("%m-%d-%Y_%H:%M:%S") + "\tError in account creation: ", e)
......
tasks.py 0 → 100644
from celery import Celery
import time
from flask_socketio import SocketIO
from gevent import monkey
monkey.patch_all(subprocess=True)
celery = Celery('flask_user_reg', broker='amqp://')
socketio = SocketIO(message_queue='amqp:///socketio')
@celery.task
def celery_create_account(username, fullname, reason, room):
# Todo: Ravi's and Louis's code goes here
print(time.strftime("%m-%d-%Y_%H:%M:%S") + '\tUser ' + username + ' added to queue')
socketio.emit("creating account", room=room)
time.sleep(5)
socketio.emit('account ready', room=room)
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