From 6fddb9ded4800abd01ef3ffb165bf0bdabf470fe Mon Sep 17 00:00:00 2001 From: root <root@login001.cm.cluster> Date: Fri, 2 Apr 2021 09:25:17 -0500 Subject: [PATCH] added timeout function on client end --- tasks.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tasks.py b/tasks.py index 6b5973a..b28dbbb 100644 --- a/tasks.py +++ b/tasks.py @@ -14,7 +14,7 @@ broker_url = vars.broker_url celery = Celery('flask_user_reg', broker=broker_url) socketio = SocketIO(message_queue=vars.message_queue) -timeout = 60 +timeout = 30 def gen_f(room): def callback(channel, method, properties, body): @@ -40,7 +40,9 @@ def send_msg(event, room): def timeout_handler(signum, frame): print("Process timeout, there's might some issue with agents") + socketio.emit('account error', errmsg, room= room) rc_util.rc_rmq.stop_consume() + rc_util.rc_rmq.delete_queue() @celery.task def celery_create_account(json, session): @@ -52,11 +54,11 @@ def celery_create_account(json, session): print(time.strftime("%m-%d-%Y_%H:%M:%S") + '\tUser ' + username + ' added to queue') send_msg('creating account', room) + signal.signal(signal.SIGALRM, timeout_handler) + signal.setitimer(signal.ITIMER_REAL, timeout) print(username) rc_util.add_account(username, email, fullname, reason) print('sent account info') - - print('Waiting for completion...') #print(callback(self.EXCHANGE, self.EXCHANGE,self.EXCHANGE,self.EXCHANGE)) rc_util.consume(username, routing_key=f'complete.{username}', callback=gen_f(room)) -- GitLab