-
Notifications
You must be signed in to change notification settings - Fork 95
/
Copy pathconf.py
65 lines (54 loc) · 2.44 KB
/
conf.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
from django.conf import settings # noqa
from django.core.exceptions import ImproperlyConfigured
from haystack import constants
from haystack.management.commands import update_index as cmd
from appconf import AppConf
class CeleryHaystack(AppConf):
#: The default alias to
DEFAULT_ALIAS = None
#: The delay (in seconds) before task will be executed (Celery countdown)
COUNTDOWN = 0
#: The delay (in seconds) after which a failed index is retried
RETRY_DELAY = 5 * 60
#: The number of retries that are done
MAX_RETRIES = 1
#: The default Celery task class
DEFAULT_TASK = 'celery_haystack.tasks.CeleryHaystackSignalHandler'
#: The name of the celery queue to use, or None for default
QUEUE = None
#: Whether the task should be handled transaction safe
TRANSACTION_SAFE = True
#: Whether the task shoild ignore results
IGNORE_RESULTS = False
#: The batch size used by the CeleryHaystackUpdateIndex task
COMMAND_BATCH_SIZE = None
#: The max age of items used by the CeleryHaystackUpdateIndex task
COMMAND_AGE = None
#: Wehther to remove items from the index that aren't in the DB anymore
COMMAND_REMOVE = False
#: The number of multiprocessing workers used by the CeleryHaystackUpdateIndex task
COMMAND_WORKERS = 0
#: The names of apps to run update_index for
COMMAND_APPS = []
#: The verbosity level of the update_index call
COMMAND_VERBOSITY = 1
def configure_default_alias(self, value):
return value or getattr(constants, 'DEFAULT_ALIAS', None)
def configure_command_batch_size(self, value):
return value or getattr(cmd, 'DEFAULT_BATCH_SIZE', None)
def configure_command_age(self, value):
return value or getattr(cmd, 'DEFAULT_AGE', None)
def configure(self):
data = {}
for name, value in self.configured_data.items():
if name in ('RETRY_DELAY', 'MAX_RETRIES',
'COMMAND_WORKERS', 'COMMAND_VERBOSITY'):
value = int(value)
data[name] = value
return data
signal_processor = getattr(settings, 'HAYSTACK_SIGNAL_PROCESSOR', None)
if signal_processor is None:
raise ImproperlyConfigured("When using celery-haystack with Haystack 2.X "
"the HAYSTACK_SIGNAL_PROCESSOR setting must be "
"set. Use 'celery_haystack.signals."
"CelerySignalProcessor' as default.")