Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
RECIRCLE
/
portal
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
11
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
b5ba0825
authored
Apr 22, 2020
by
Chif Gergő
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test polling works
parent
a587ac4e
Pipeline
#1084
failed with stage
in 2 minutes 24 seconds
Changes
5
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
28 additions
and
11 deletions
+28
-11
recircle/celerybeat-schedule
+0
-0
recircle/recircle/__init__.py
+0
-7
recircle/recircle/celery.py
+19
-3
recircle/recircle/settings/base.py
+8
-1
recircle/status/tasks.py
+1
-0
No files found.
recircle/celerybeat-schedule
0 → 100644
View file @
b5ba0825
File added
recircle/recircle/__init__.py
View file @
b5ba0825
from
__future__
import
absolute_import
,
unicode_literals
# This will make sure the app is always imported when
# Django starts so that shared_task will use this app.
from
.celery
import
app
as
celery_app
__all__
=
(
'celery_app'
,)
recircle/recircle/celery.py
View file @
b5ba0825
...
...
@@ -5,15 +5,17 @@ import os
from
celery
import
Celery
# set the default Django settings module for the 'celery' program.
os
.
environ
.
setdefault
(
'DJANGO_SETTINGS_MODULE'
,
'
proj.settings
'
)
os
.
environ
.
setdefault
(
'DJANGO_SETTINGS_MODULE'
,
'
recircle.settings.base
'
)
app
=
Celery
(
'
proj
'
)
app
=
Celery
(
'
recircle
'
)
# Using a string here means the worker doesn't have to serialize
# the configuration object to child processes.
# - namespace='CELERY' means all celery-related configuration keys
# should have a `CELERY_` prefix.
app
.
config_from_object
(
'django.conf:settings'
,
namespace
=
'CELERY'
)
# app.config_from_object('django.conf:settings.base', namespace='CELERY')
app
.
conf
.
broker_url
=
'redis://localhost:6379/0'
# Load task modules from all registered Django app configs.
app
.
autodiscover_tasks
()
...
...
@@ -22,3 +24,17 @@ app.autodiscover_tasks()
@app.task
(
bind
=
True
)
def
debug_task
(
self
):
print
(
'Request: {0!r}'
.
format
(
self
.
request
))
# Testing the periodic tasks
@app.on_after_configure.connect
def
setup_periodic_tasks
(
sender
,
**
kwargs
):
# Calls test('hello') every 10 seconds.
sender
.
add_periodic_task
(
10.0
,
test
.
s
(
'hello'
),
name
=
'add every 10'
)
@app.task
def
test
(
arg
):
from
instance.models
import
Instance
for
instance
in
Instance
.
objects
.
all
():
instance
.
update_status
()
recircle/recircle/settings/base.py
View file @
b5ba0825
...
...
@@ -43,7 +43,8 @@ INSTALLED_APPS = [
"corsheaders"
,
"guardian"
,
"django_nose"
,
"channels"
"channels"
,
"django_celery_beat"
,
]
LOCAL_APPS
=
[
...
...
@@ -243,6 +244,8 @@ AUTHENTICATION_BACKENDS = (
'guardian.backends.ObjectPermissionBackend'
,
)
# Channels settings
CHANNEL_LAYERS
=
{
'default'
:
{
'BACKEND'
:
'channels_redis.core.RedisChannelLayer'
,
...
...
@@ -253,3 +256,7 @@ CHANNEL_LAYERS = {
}
ASGI_APPLICATION
=
"recircle.routing.application"
# Celery settings
CELERY_BROKER_URL
=
"redis://localhost:6379/0"
recircle/status/tasks.py
0 → 100644
View file @
b5ba0825
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