diff options
author | Filipp Lepalaan <filipp@mac.com> | 2021-06-06 16:21:28 +0300 |
---|---|---|
committer | Filipp Lepalaan <filipp@mac.com> | 2021-06-06 16:21:28 +0300 |
commit | 4b2d491c2908ec6b677fe494547774bf7d323cb5 (patch) | |
tree | 33ded17f17e2113d7236bac6519f54cb7ce8d914 | |
parent | ff6433f6410f1669e74dcb933250e543f8223cd7 (diff) | |
download | Servo-4b2d491c2908ec6b677fe494547774bf7d323cb5.tar.gz Servo-4b2d491c2908ec6b677fe494547774bf7d323cb5.tar.bz2 Servo-4b2d491c2908ec6b677fe494547774bf7d323cb5.zip |
Fix django.core.exceptions.AppRegistryNotReady in scheduler
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | servo/__init__.py | 5 | ||||
-rw-r--r-- | servo/celery.py | 24 | ||||
-rw-r--r-- | servo/management/commands/scheduler.py | 5 | ||||
-rw-r--r-- | servo/tasks.py | 8 |
5 files changed, 8 insertions, 36 deletions
@@ -56,7 +56,7 @@ For testing, you can run Servo without any extra setup: If you want to run rules, set ENABLE_RULES = True and start the worker task and scheduler: - $ ./manage.py rqworker & + $ rq worker --with-scheduler & $ ./manage.py scheduler Then fire up your browser and got to [http://localhost:8000/](http://localhost:8000/) diff --git a/servo/__init__.py b/servo/__init__.py index b64e43e..e69de29 100644 --- a/servo/__init__.py +++ b/servo/__init__.py @@ -1,5 +0,0 @@ -from __future__ import absolute_import - -# 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 diff --git a/servo/celery.py b/servo/celery.py deleted file mode 100644 index 75dc4d7..0000000 --- a/servo/celery.py +++ /dev/null @@ -1,24 +0,0 @@ -# -*- coding: utf-8 -*- - -from __future__ import absolute_import - -import os - -from celery import Celery - -# set the default Django settings module for the 'celery' program. -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'settings') - -from django.conf import settings - -app = Celery('servo') - -# Using a string here means the worker will not have to -# pickle the object when using Windows. -app.config_from_object('django.conf:settings') -app.autodiscover_tasks(lambda: settings.INSTALLED_APPS) - - -@app.task(bind=True) -def debug_task(self): - print('Request: {0!r}'.format(self.request)) diff --git a/servo/management/commands/scheduler.py b/servo/management/commands/scheduler.py index 18018e5..c400b7b 100644 --- a/servo/management/commands/scheduler.py +++ b/servo/management/commands/scheduler.py @@ -1,9 +1,12 @@ from datetime import datetime -import django_rq +import django + from django.core.management.base import BaseCommand from django_rq.management.commands import rqscheduler +import django_rq +django.setup() # To avoid django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet. from servo.tasks import check_mail diff --git a/servo/tasks.py b/servo/tasks.py index 1d55136..c31dd22 100644 --- a/servo/tasks.py +++ b/servo/tasks.py @@ -1,9 +1,6 @@ # -*- coding: utf-8 -*- -import email -import logging from email.parser import BytesParser -from django.conf import settings from django.core.cache import cache from servo.lib.utils import empty @@ -12,10 +9,11 @@ from servo.models import Configuration, User, Order, Note, Template def get_rules(): - """Get the rules from the JSON file and cache them. + """ + Get the rules from the JSON file and cache them. Fail silently if not configured. - @FIXME: Need GUI for managing local_rules.json! + @TODO: Need GUI for managing local_rules.json! """ import json |