Skip to content

Commit 4fad083

Browse files
committed
make exception handlers use package settings and match implementation to documentation
1 parent 2c3a17c commit 4fad083

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

README.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ Installation
5050
'high': {
5151
'URL': os.getenv('REDISTOGO_URL', 'redis://localhost:6379/0'), # If you're on Heroku
5252
'DEFAULT_TIMEOUT': 500,
53-
'EXCEPTION_HANDLERS': ['path.to.my.handler'], # If you need custom exception handlers
5453
},
5554
'low': {
5655
'HOST': 'localhost',
@@ -59,6 +58,8 @@ Installation
5958
}
6059
}
6160
61+
RQ_EXCEPTION_HANDLERS = ['path.to.my.handler'] # If you need custom exception handlers
62+
6263
* Include ``django_rq.urls`` in your ``urls.py``:
6364

6465
.. code-block:: python

django_rq/settings.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,6 @@
1717
QUEUES_LIST.append({'name': key, 'connection_config': value})
1818
for config in get_unique_connection_configs():
1919
QUEUES_LIST.append({'name': 'failed', 'connection_config': config})
20+
21+
# Get exception handlers
22+
EXCEPTION_HANDLERS = getattr(settings, 'RQ_EXCEPTION_HANDLERS', [])

django_rq/workers.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
from django.conf import settings
2-
31
from rq import Worker
42
from rq.utils import import_attribute
53

64
from .queues import get_queues
5+
from .settings import EXCEPTION_HANDLERS
76

87

98
def get_exception_handlers():
@@ -13,12 +12,7 @@ def get_exception_handlers():
1312
'EXCEPTION_HANDLERS': ['path.to.handler'],
1413
}
1514
"""
16-
RQ = getattr(settings, 'RQ', {})
17-
exception_handlers = []
18-
for path in RQ.get('EXCEPTION_HANDLERS', []):
19-
handler = import_attribute(path)
20-
exception_handlers.append(handler)
21-
return exception_handlers
15+
return [import_attribute(path) for path in EXCEPTION_HANDLERS]
2216

2317

2418
def get_worker(*queue_names):

0 commit comments

Comments
 (0)