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
5350f832
Commit
5350f832
authored
Aug 31, 2016
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add celery usage more
parent
dd80b94b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
3 deletions
+14
-3
README.md
apps/common/README.md
+7
-0
celery.py
apps/common/celery.py
+0
-1
tasks.py
apps/ops/tasks.py
+7
-2
No files found.
apps/common/README.md
View file @
5350f832
...
...
@@ -22,6 +22,7 @@ from __future__ import absolute_import
import time
from celery import shared_task
from common import celery_app
@shared_task
...
...
@@ -31,6 +32,12 @@ def longtime_add(x, y):
time.sleep(5)
print 'long time task finished'
return x + y
@celery_app.task(name='hello-world')
def hello():
print 'hello world!'
```
#### Run celery in development
...
...
apps/common/celery.py
View file @
5350f832
...
...
@@ -17,6 +17,5 @@ app = Celery('jumpserver')
# pickle the object when using Windows.
app
.
config_from_object
(
'django.conf:settings'
)
print
(
settings
.
BROKER_URL
)
app
.
autodiscover_tasks
(
lambda
:
[
app_config
.
split
(
'.'
)[
0
]
for
app_config
in
settings
.
INSTALLED_APPS
])
apps/ops/tasks.py
View file @
5350f832
...
...
@@ -2,6 +2,7 @@ from __future__ import absolute_import
import
time
from
celery
import
shared_task
from
common
import
celery_app
@shared_task
...
...
@@ -10,4 +11,9 @@ def longtime_add(x, y):
# sleep 5 seconds
time
.
sleep
(
5
)
print
'long time task finished'
return
x
+
y
\ No newline at end of file
return
x
+
y
@celery_app.task
(
name
=
'hello-world'
)
def
hello
():
print
(
'hello world!'
)
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