Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project updates and bug fixes #138

Merged
merged 1 commit into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ shell-huey2: ## go into a interactive bash shell in Huey worker container 2
shell-huey3: ## go into a interactive bash shell in Huey worker container 3
./compose.sh exec huey3 /bin/bash

shell-redis: ## go into a interactive bash shell in Redis container
./compose.sh exec redis /bin/ash

logs: ## Display and follow docker logs
./compose.sh logs --tail=500 --follow

Expand Down
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ run-shell-django Build and start the Django container and go into
shell-huey1 go into a interactive bash shell in Huey worker container 1
shell-huey2 go into a interactive bash shell in Huey worker container 2
shell-huey3 go into a interactive bash shell in Huey worker container 3
shell-redis go into a interactive bash shell in Redis container
logs Display and follow docker logs
logs-django Display and follow docker logs only from "django" container
reload-django Reload the Django dev server
Expand Down Expand Up @@ -224,8 +225,19 @@ You must change your Django settings and replace the app name:

## History

* [dev](https://github.com/boxine/django-huey-monitor/compare/v0.8.1...main)
* [dev](https://github.com/boxine/django-huey-monitor/compare/v0.9.0...main)
* _tbc_
* [v0.9.0 - 22.12.2023](https://github.com/boxine/django-huey-monitor/compare/v0.8.1...v0.9.0)
* Fix #135 DisallowedModelAdminLookup
* Add "thread" name as change list filter.
* Enhance test project setup
* Apply manageprojects updates
* Remove Python v3.9 support
* Add Django v5.0 to test matrix and remove Django 4.1
* Enable local AUTOLOGIN as default
* Use unittest "load_tests Protocol" and deny any requests in tests
* Add https://github.com/PyCQA/flake8-bugbear
* Update requirements
* [v0.8.1 - 20.11.2023](https://github.com/boxine/django-huey-monitor/compare/v0.8.0...v0.8.1)
* Bugfix `ZeroDivisionError` in admin
* [v0.8.0 - 20.11.2023](https://github.com/boxine/django-huey-monitor/compare/v0.7.1...v0.8.0)
Expand Down
2 changes: 1 addition & 1 deletion docker/huey/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ echo "$(date +%c) - ${0} $*"
/django/docker/utils/init.sh "${1}"

./manage.py --help
watchfiles --filter python "python manage.py run_huey --worker-type process --workers 2" /django/
watchfiles --filter python "python manage.py run_huey --worker-type greenlet --workers 4" /django/
echo "Huey terminated with exit code: $?"
sleep 3
exit 1
Expand Down
2 changes: 1 addition & 1 deletion huey_monitor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
Django based tool for monitoring huey task queue: https://github.com/coleifer/huey
"""

__version__ = '0.8.1'
__version__ = '0.9.0'
__author__ = 'Jens Diemer <[email protected]>'
13 changes: 13 additions & 0 deletions huey_monitor/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,22 @@ def get_urls(self):
(_('Hierarchy'), {'fields': ('task_hierarchy_info',)}),
)

def lookup_allowed(self, lookup, value):
if lookup in (
'state__signal_name',
'state__thread',
'state__hostname',
):
# Work-a-round for: https://code.djangoproject.com/ticket/35020
# FIXME: Remove after release.
return True
return super().lookup_allowed(lookup, value)

def get_list_filter(self, request):
return getattr(settings, 'HUEY_MONITOR_TASK_MODEL_LIST_FILTER', None) or (
'name',
'state__signal_name',
'state__thread',
'state__hostname',
)

Expand Down Expand Up @@ -199,6 +211,7 @@ def get_list_filter(self, request):
return getattr(settings, 'HUEY_MONITOR_SIGNAL_INFO_MODEL_LIST_FILTER', None) or (
'task__name',
'signal_name',
'thread',
'hostname',
)

Expand Down
9 changes: 9 additions & 0 deletions huey_monitor_project/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
Allow django-huey-monitor to be executable
through `python -m huey_monitor`.
"""

import sys

from manage_django_project.manage import execute_django_from_command_line


Expand All @@ -10,6 +13,12 @@ def main():
entrypoint installed via pyproject.toml and [project.scripts] section.
Must be set in ./manage.py and PROJECT_SHELL_SCRIPT
"""
if 'greenlet' in sys.argv:
# Worker start -> https://www.gevent.org/intro.html#monkey-patching
from gevent import monkey

monkey.patch_all()

execute_django_from_command_line()


Expand Down
3 changes: 2 additions & 1 deletion huey_monitor_project/settings/docker.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import sys as __sys

from huey_monitor_project import huey_docker_instance
from huey_monitor_project.settings.local import * # noqa
Expand All @@ -22,7 +23,7 @@
'CONN_MAX_AGE': 600,
},
}

print(f'Use Database: {DATABASES["default"]["NAME"]!r}', file=__sys.stderr)

# # _____________________________________________________________________________
# # Django debug toolbar
Expand Down
3 changes: 1 addition & 2 deletions huey_monitor_project/settings/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"""

import os as __os
import sys as __sys

from huey_monitor_project import huey_tests_instance
from huey_monitor_project.settings.prod import * # noqa
Expand Down Expand Up @@ -51,7 +50,7 @@
'timeout': 30,
}
}
print(f'Use Database: {DATABASES["default"]["NAME"]!r}', file=__sys.stderr)


# _____________________________________________________________________________

Expand Down
14 changes: 9 additions & 5 deletions huey_monitor_project/settings/prod.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
# ----------------------------------------------------------------------------

# e.g.: override SignalInfoModelAdmin.list_filter:
HUEY_MONITOR_SIGNAL_INFO_MODEL_LIST_FILTER = ('task__name', 'signal_name', 'hostname')
HUEY_MONITOR_SIGNAL_INFO_MODEL_LIST_FILTER = ('task__name', 'signal_name', 'thread', 'hostname')

# e.g.: override TaskModelAdmin.list_filter:
HUEY_MONITOR_TASK_MODEL_LIST_FILTER = ('name', 'state__signal_name', 'state__hostname')
HUEY_MONITOR_TASK_MODEL_LIST_FILTER = ('name', 'state__signal_name', 'state__thread', 'state__hostname')


# Django settings
Expand Down Expand Up @@ -174,14 +174,18 @@ def record_factory(*args, **kwargs):
'formatters': {
'colored': { # https://github.com/borntyping/python-colorlog
'()': 'colorlog.ColoredFormatter',
'format': '%(log_color)s%(asctime)s %(levelname)8s %(cut_path)s:%(lineno)-3s %(message)s',
'format': (
'%(log_color)s%(asctime)s'
' %(levelname)8s %(processName)s %(threadName)s'
' %(cut_path)s:%(lineno)-3s %(message)s'
),
}
},
'handlers': {'console': {'class': 'colorlog.StreamHandler', 'formatter': 'colored'}},
'loggers': {
'': {'handlers': ['console'], 'level': 'DEBUG', 'propagate': False},
'': {'handlers': ['console'], 'level': 'INFO', 'propagate': False},
'django': {'handlers': ['console'], 'level': 'INFO', 'propagate': False},
'huey': {'handlers': ['console'], 'level': 'DEBUG', 'propagate': False},
'huey': {'handlers': ['console'], 'level': 'INFO', 'propagate': False},
'huey_monitor': {'handlers': ['console'], 'level': 'DEBUG', 'propagate': False},
'huey_monitor_tests': {'handlers': ['console'], 'level': 'DEBUG', 'propagate': False},
},
Expand Down
5 changes: 4 additions & 1 deletion manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,10 @@ def main(argv):
verbose_check_call(PIP_PATH, 'install', '--no-deps', '-e', '.')
store_dep_hash()

signal.signal(signal.SIGINT, noop_sigint_handler) # ignore "Interrupt from keyboard" signals
if 'run_dev_server' not in argv and 'run_huey' not in argv:
# ignore "Interrupt from keyboard" signals
# But not if we run the dev server or Huey consumer (respect watchfiles signals)
signal.signal(signal.SIGINT, noop_sigint_handler)

# Call our entry point CLI:
try:
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ dependencies = [
]
[project.optional-dependencies]
dev = [
"gevent", # https://github.com/gevent/gevent
"django-redis",
"psycopg2-binary",
"manage_django_project", # https://github.com/jedie/manage_django_project
Expand Down
Loading
Loading