-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #128 from boxine/dev
Fix #127: Catch error getting HUEY counts
- Loading branch information
Showing
3 changed files
with
32 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,5 @@ | |
Django based tool for monitoring huey task queue: https://github.com/coleifer/huey | ||
""" | ||
|
||
__version__ = '0.7.0' | ||
__version__ = '0.7.1' | ||
__author__ = 'Jens Diemer <[email protected]>' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,26 @@ | ||
import logging | ||
|
||
from django import template | ||
from django.template.loader import render_to_string | ||
from huey.contrib.djhuey import HUEY | ||
|
||
|
||
logger = logging.getLogger(__name__) | ||
register = template.Library() | ||
|
||
|
||
@register.simple_tag | ||
def huey_counts_info(): | ||
context = dict( | ||
huey_pending_count=HUEY.pending_count(), | ||
huey_scheduled_count=HUEY.scheduled_count(), | ||
huey_result_count=HUEY.result_count(), | ||
) | ||
return render_to_string('admin/huey_monitor/huey_counts_info.html', context) | ||
try: | ||
context = dict( | ||
huey_pending_count=HUEY.pending_count(), | ||
huey_scheduled_count=HUEY.scheduled_count(), | ||
huey_result_count=HUEY.result_count(), | ||
) | ||
except OSError as err: | ||
# e.g.: Redis down or other setup used see #127 | ||
logger.exception('Failed to get counts from HUEY: %s', err) | ||
|
||
return f'<p>Huey counts: ({type(err).__name__}: {err})</p>' | ||
else: | ||
return render_to_string('admin/huey_monitor/huey_counts_info.html', context) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters