Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
circlestack
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
f8bb2ede
authored
Mar 14, 2014
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vm: cache list of queues
parent
1db410a2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
3 deletions
+30
-3
circle/vm/tasks/vm_tasks.py
+30
-3
No files found.
circle/vm/tasks/vm_tasks.py
View file @
f8bb2ede
from
django.core.cache
import
cache
from
logging
import
getLogger
from
manager.mancelery
import
celery
logger
=
getLogger
(
__name__
)
def
check_queue
(
node_hostname
,
queue_id
):
"""True if the queue is alive.
Example: check_queue('node01', 'vm'):
:param node_hostname: Short hostname of the node.
:param queue_id: Queue identifier (eg. vm).
"""
drivers
=
[
'vmdriver'
,
'netdriver'
,
'agentdriver'
]
worker_list
=
[
node_hostname
+
"."
+
d
for
d
in
drivers
]
#
worker_list = [node_hostname + "." + d for d in drivers]
queue_name
=
node_hostname
+
"."
+
queue_id
inspect
=
celery
.
control
.
inspect
(
worker_list
)
active_queues
=
inspect
.
active_queues
()
active_queues
=
get_queues
()
if
active_queues
is
None
:
return
False
# v is List of List of queues dict
...
...
@@ -17,6 +27,23 @@ def check_queue(node_hostname, queue_id):
return
True
return
False
def
get_queues
():
"""Get active celery queues.
Result is cached for 10 seconds!
"""
key
=
__name__
+
u'queues'
result
=
cache
.
get
(
key
)
if
result
is
None
:
inspect
=
celery
.
control
.
inspect
()
inspect
.
timeout
=
0.1
result
=
inspect
.
active_queues
()
logger
.
debug
(
'Queue list of length
%
d cached.'
,
len
(
result
))
cache
.
set
(
key
,
result
,
10
)
return
result
@celery.task
(
name
=
'vmdriver.create'
)
def
deploy
(
params
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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