diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2019-01-11 20:38:36 +0100 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2019-01-11 20:38:36 +0100 |
| commit | 334ea5a2a91da853dc6faf7f48aaa12599201218 (patch) | |
| tree | 24c469d58ae7c15d09f0dc76836756af2fa4ff51 /megapixels/app/server/tasks/__init__.py | |
| parent | 3202498b5c195f103a7cd13609785c2bb97c2da6 (diff) | |
enable celery tasks
Diffstat (limited to 'megapixels/app/server/tasks/__init__.py')
| -rw-r--r-- | megapixels/app/server/tasks/__init__.py | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/megapixels/app/server/tasks/__init__.py b/megapixels/app/server/tasks/__init__.py new file mode 100644 index 00000000..bac7309f --- /dev/null +++ b/megapixels/app/server/tasks/__init__.py @@ -0,0 +1,47 @@ +import simplejson as json +from app.settings import app_cfg as cfg +from celery import Celery + +celery = Celery(__name__, backend=cfg.CELERY_RESULT_BACKEND, broker=cfg.CELERY_BROKER_URL) + +from app.server.tasks.sleep import sleep_task +# from app.server.tasks.blur import blur_task + +def list_active_tasks(): + dropdown = {} + for k,v in task_lookup.items(): + if 'active' not in v or v['active'] is not False: + is_default = 'default' in v and v['default'] is True + task = { + 'name': k, + 'title': v['title'], + 'selected': is_default, + } + dropdown[k] = task + return dropdown + +################################################################### +# Add all valid tasks to this lookup. +# Set 'active': False to disable a task +# Set 'default': True to define the default task + +task_lookup = { + 'sleep': { + 'title': 'Sleep Test', + 'task': sleep_task, + 'active': True, + 'default': True, + }, + # 'blur': { + # 'title': 'Blur', + # 'task': blur_task, + # 'active': False, + # }, + # 'task_dull': { + # 'title': 'DullDream V2', + # 'task': task_dull, + # 'active': True, + # 'default': True, + # } +} + |
