|
3 | 3 | import os
|
4 | 4 | import imp
|
5 | 5 | import importlib
|
6 |
| -import warnings |
7 | 6 |
|
8 | 7 | from datetime import datetime
|
| 8 | +from warnings import warn |
9 | 9 |
|
10 | 10 | from celery import signals
|
11 | 11 | from celery.datastructures import DictAttribute
|
@@ -64,7 +64,7 @@ def read_configuration(self):
|
64 | 64 | settings.CELERY_RESULT_BACKEND = 'database'
|
65 | 65 | if NO_TZ:
|
66 | 66 | if getattr(settings, 'CELERY_ENABLE_UTC', None):
|
67 |
| - warnings.warn('CELERY_ENABLE_UTC requires Django 1.4+') |
| 67 | + warn('CELERY_ENABLE_UTC requires Django 1.4+') |
68 | 68 | settings.CELERY_ENABLE_UTC = False
|
69 | 69 | return DictAttribute(settings)
|
70 | 70 |
|
@@ -130,8 +130,8 @@ def on_worker_init(self):
|
130 | 130 |
|
131 | 131 | def warn_if_debug(self, **kwargs):
|
132 | 132 | if settings.DEBUG:
|
133 |
| - warnings.warn('Using settings.DEBUG leads to a memory leak, never ' |
134 |
| - 'use this setting in production environments!') |
| 133 | + warn('Using settings.DEBUG leads to a memory leak, never ' |
| 134 | + 'use this setting in production environments!') |
135 | 135 |
|
136 | 136 | def import_default_modules(self):
|
137 | 137 | super(DjangoLoader, self).import_default_modules()
|
@@ -184,7 +184,12 @@ def find_related_module(app, related_name):
|
184 | 184 |
|
185 | 185 | try:
|
186 | 186 | app_path = importlib.import_module(app).__path__
|
187 |
| - except (AttributeError, ImportError): |
| 187 | + except ImportError as exc: |
| 188 | + warn('Autodiscover: Error importing %s.%s: %r' % ( |
| 189 | + app, related_name, exc, |
| 190 | + )) |
| 191 | + return |
| 192 | + except AttributeError: |
188 | 193 | return
|
189 | 194 |
|
190 | 195 | try:
|
|
0 commit comments