Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
self-reg-form
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
3
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Krish Moodbidri
self-reg-form
Commits
a7358eec
Commit
a7358eec
authored
4 years ago
by
Krish Moodbidri
Browse files
Options
Downloads
Patches
Plain Diff
added timeout function
parent
b84cd7e2
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#4254
failed with stage
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tasks.py
+11
-0
11 additions, 0 deletions
tasks.py
with
11 additions
and
0 deletions
tasks.py
+
11
−
0
View file @
a7358eec
...
...
@@ -2,6 +2,7 @@ import vars
import
sys
import
json
import
time
import
signal
from
celery
import
Celery
from
flask_socketio
import
SocketIO
...
...
@@ -13,6 +14,7 @@ broker_url = vars.broker_url
celery
=
Celery
(
'
flask_user_reg
'
,
broker
=
broker_url
)
socketio
=
SocketIO
(
message_queue
=
vars
.
message_queue
)
timeout
=
60
def
callback
(
channel
,
method
,
properties
,
body
):
msg
=
json
.
loads
(
body
)
...
...
@@ -33,6 +35,9 @@ def send_msg(event, room):
print
(
"
Post
'
{}
'
to room
'
{}
'"
.
format
(
event
,
room
))
socketio
.
emit
(
event
,
room
=
room
)
def
timeout_handler
(
signum
,
frame
):
print
(
"
Process timeout, there
'
s might some issue with agents
"
)
rc_util
.
rc_rmq
.
stop_consume
()
@celery.task
def
celery_create_account
(
json
,
session
):
...
...
@@ -47,6 +52,12 @@ def celery_create_account(json, session):
print
(
username
)
rc_util
.
add_account
(
username
,
email
,
fullname
,
reason
)
print
(
'
sent account info
'
)
# Set initial timeout timer
signal
.
signal
(
signal
.
SIGALRM
,
timeout_handler
)
signal
.
setitimer
(
signal
.
ITIMER_REAL
,
timeout
)
print
(
'
Waiting for completion...
'
)
rc_util
.
consume
(
username
,
routing_key
=
f
'
complete.
{
username
}
'
,
callback
=
callback
)
send_msg
(
'
account ready
'
,
room
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment