Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Krish Moodbidri
self-reg-form
Commits
ff4505b0
Commit
ff4505b0
authored
Mar 10, 2021
by
Krish Moodbidri
Browse files
added callback function with error print to command line
parent
c95fc667
Pipeline
#4249
failed with stage
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
tasks.py
View file @
ff4505b0
...
...
@@ -4,6 +4,7 @@ from flask_socketio import SocketIO
import
subprocess
import
vars
import
sys
import
json
sys
.
path
.
append
(
'/cm/shared/rabbitmq_agents/'
)
import
rc_util
...
...
@@ -16,7 +17,18 @@ celery = Celery('flask_user_reg', broker=broker_url)
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
.
delete_queue
()
...
...
@@ -39,4 +51,5 @@ def celery_create_account(json, session):
rc_util
.
add_account
(
username
,
email
,
fullname
,
reason
)
print
(
'sent account info'
)
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
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment