Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jumpserver
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
jumpserver
Commits
97a2e8bb
Commit
97a2e8bb
authored
9 years ago
by
yumaojun03
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test add celery
parent
8b0f31c4
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
0 deletions
+41
-0
settings.py
apps/jumpserver/settings.py
+3
-0
tasks.py
apps/ops/tasks.py
+38
-0
No files found.
apps/jumpserver/settings.py
View file @
97a2e8bb
...
...
@@ -23,6 +23,8 @@ sys.path.append(os.path.dirname(BASE_DIR))
try
:
from
config
import
config
as
env_config
,
env
CONFIG
=
env_config
.
get
(
env
,
'default'
)()
BROKER_URL
=
CONFIG
.
BROKER_URL
except
ImportError
:
CONFIG
=
type
(
'_'
,
(),
{
'__getattr__'
:
None
})()
...
...
@@ -55,6 +57,7 @@ INSTALLED_APPS = [
'django.contrib.sessions'
,
'django.contrib.messages'
,
'django.contrib.staticfiles'
,
'djcelery'
,
]
MIDDLEWARE
=
[
...
...
This diff is collapsed.
Click to expand it.
apps/ops/tasks.py
0 → 100644
View file @
97a2e8bb
from
celery
import
Celery
from
django.conf
import
settings
from
time
import
sleep
app
=
Celery
(
'ops'
,
broker
=
settings
.
BROKER_URL
)
@app.task
()
def
UploadTask
(
message
):
# Update the state. The meta data is available in task.info dicttionary
# The meta data is useful to store relevant information to the task
# Here we are storing the upload progress in the meta.
UploadTask
.
update_state
(
state
=
'PROGRESS'
,
meta
=
{
'progress'
:
0
})
sleep
(
30
)
UploadTask
.
update_state
(
state
=
'PROGRESS'
,
meta
=
{
'progress'
:
30
})
sleep
(
30
)
return
message
def
get_task_status
(
task_id
):
# If you have a task_id, this is how you query that task
task
=
UploadTask
.
AsyncResult
(
task_id
)
status
=
task
.
status
progress
=
0
if
status
==
u'SUCCESS'
:
progress
=
100
elif
status
==
u'FAILURE'
:
progress
=
0
elif
status
==
'PROGRESS'
:
progress
=
task
.
info
[
'progress'
]
return
{
'status'
:
status
,
'progress'
:
progress
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
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