5 Commits

Author SHA1 Message Date
GDay
35bea76ec3 Post spawn docs 2023-05-14 03:01:05 +02:00
David Hoover
4ba9e0338a Add post_spawn signal. (#93)
Co-authored-by: David Hoover <hooverd@arizona.edu>
2023-05-14 02:51:48 +02:00
GDay
fb960104c3 Release v1.5.2 2023-04-13 01:31:59 +02:00
GDay
88bbfd8967 Mention support for 4.2.x in docs 2023-04-13 01:21:46 +02:00
Martijn Jacobs
1f31725f43 Added Django 4.2 to the test matrix, fixed deprecation warning (#89)
* Added Django 4.2 to the CI test matrix

* Positional arguments with TimestampSigner are deprecated
2023-04-12 18:18:03 +02:00
12 changed files with 31 additions and 11 deletions

View File

@@ -12,7 +12,7 @@ jobs:
strategy: strategy:
matrix: matrix:
python-version: [ "3.8", "3.9", "3.10", "3.11" ] python-version: [ "3.8", "3.9", "3.10", "3.11" ]
django: [ "3.2", "4.1" ] django: [ "3.2", "4.1", "4.2" ]
services: services:
disque: disque:

View File

@@ -2,6 +2,13 @@
## [Unreleased](https://github.com/GDay/django-q2/tree/HEAD) ## [Unreleased](https://github.com/GDay/django-q2/tree/HEAD)
## [v1.5.2](https://github.com/GDay/django-q2/tree/v1.5.2) (2023-04-13)
**Merged pull requests:**
- Added Django 4.2 to the test matrix, fixed deprecation warning https://github.com/GDay/django-q2/pull/89
- Updated docs to show support for 4.2
## [v1.5.1](https://github.com/GDay/django-q2/tree/v1.5.1) (2023-04-02) ## [v1.5.1](https://github.com/GDay/django-q2/tree/v1.5.1) (2023-04-02)
- Fix release to pipy due to changed org name - Fix release to pipy due to changed org name

View File

@@ -40,7 +40,7 @@ Requirements
- `Django <https://www.djangoproject.com>`__ > = 3.2 - `Django <https://www.djangoproject.com>`__ > = 3.2
- `Django-picklefield <https://github.com/gintas/django-picklefield>`__ - `Django-picklefield <https://github.com/gintas/django-picklefield>`__
Tested with: Python 3.8, 3.9, 3.10, 3.11 Django 3.2.X and 4.1.X Tested with: Python 3.8, 3.9, 3.10 and 3.11. Works with Django 3.2.X, 4.1.X and 4.2.X.
Brokers Brokers
~~~~~~~ ~~~~~~~

View File

@@ -1,6 +1,6 @@
import django import django
VERSION = (1, 5, 1) VERSION = (1, 5, 2)
if django.VERSION < (3, 2): if django.VERSION < (3, 2):
default_app_config = "django_q.apps.DjangoQConfig" default_app_config = "django_q.apps.DjangoQConfig"

View File

@@ -39,7 +39,7 @@ from django_q.conf import (
from django_q.humanhash import humanize from django_q.humanhash import humanize
from django_q.models import Schedule, Success, Task from django_q.models import Schedule, Success, Task
from django_q.queues import Queue from django_q.queues import Queue
from django_q.signals import post_execute, pre_execute from django_q.signals import post_execute, post_spawn, pre_execute
from django_q.signing import BadSignature, SignedPackage from django_q.signing import BadSignature, SignedPackage
from django_q.status import Stat, Status from django_q.status import Stat, Status
@@ -481,6 +481,7 @@ def worker(
_("%(proc_name)s ready for work at %(id)s") _("%(proc_name)s ready for work at %(id)s")
% {"proc_name": proc_name, "id": current_process().pid} % {"proc_name": proc_name, "id": current_process().pid}
) )
post_spawn.send(sender="django_q", proc_name=proc_name)
if setproctitle: if setproctitle:
setproctitle.setproctitle(f"qcluster {proc_name} idle") setproctitle.setproctitle(f"qcluster {proc_name} idle")
task_count = 0 task_count = 0

View File

@@ -37,7 +37,7 @@ def loads(
""" """
# TimestampSigner.unsign() returns str but base64 and zlib compression # TimestampSigner.unsign() returns str but base64 and zlib compression
# operate on bytes. # operate on bytes.
base64d = force_bytes(TimestampSigner(key, salt=salt).unsign(s, max_age=max_age)) base64d = force_bytes(TimestampSigner(key=key, salt=salt).unsign(s, max_age=max_age))
decompress = False decompress = False
if base64d[:1] == b".": if base64d[:1] == b".":
# It's compressed; uncompress it first # It's compressed; uncompress it first

View File

@@ -31,6 +31,8 @@ def call_hook(sender, instance, **kwargs):
% {"hook": instance.hook, "name": instance.name, "error": str(e)} % {"hook": instance.hook, "name": instance.name, "error": str(e)}
) )
# args: proc_name
post_spawn = Signal()
# args: task # args: task
pre_enqueue = Signal() pre_enqueue = Signal()

View File

@@ -75,7 +75,7 @@ author = "Ilan Steemers, Stan Triepels"
# The short X.Y version. # The short X.Y version.
version = "1.5" version = "1.5"
# The full version, including alpha/beta/rc tags. # The full version, including alpha/beta/rc tags.
release = "1.5.1" release = "1.5.2"
# The language for content autogenerated by Sphinx. Refer to documentation # The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages. # for a list of supported languages.

View File

@@ -27,7 +27,7 @@ Features
- Rollbar and Sentry support - Rollbar and Sentry support
Django Q2 is tested with: Python 3.8, 3.9 and 3.10, 3.11, Django 3.2.x and 4.1.x Django Q2 is tested with: Python 3.8, 3.9, 3.10 and 3.11. Works with Django 3.2.x, 4.1.x and 4.2.x
Currently available in English, German and French. Currently available in English, German and French.

View File

@@ -32,7 +32,7 @@ Django Q2 is tested for Python 3.8, 3.9, 3.10 and 3.11
- `Django <https://www.djangoproject.com>`__ - `Django <https://www.djangoproject.com>`__
Django Q2 aims to use as much of Django's standard offerings as possible. Django Q2 aims to use as much of Django's standard offerings as possible.
The code is tested against Django versions `3.2.x` and `4.1.x`. The code is tested against Django versions `3.2.x`, `4.1.x` and`4.2.x`.
- `Django-picklefield <https://github.com/gintas/django-picklefield>`__ - `Django-picklefield <https://github.com/gintas/django-picklefield>`__
@@ -140,7 +140,7 @@ You can reference the `requirements <https://github.com/GDay/django-q2/blob/mast
Django Django
~~~~~~ ~~~~~~
We strive to be compatible with last two major version of Django. We strive to be compatible with last two major version of Django.
At the moment this means we support the 3.2.x and 4.1.x releases. At the moment this means we support the 3.2.x, 4.1.x and 4.2.x releases.
Since we are now no longer supporting Python 2, we can also not support older versions of Django that do not support Python >= 3.6 Since we are now no longer supporting Python 2, we can also not support older versions of Django that do not support Python >= 3.6
For this you can always use older releases, but they are no longer maintained. For this you can always use older releases, but they are no longer maintained.

View File

@@ -13,6 +13,12 @@ Before enqueuing a task
The ``django_q.signals.pre_enqueue`` signal is emitted before a task is The ``django_q.signals.pre_enqueue`` signal is emitted before a task is
enqueued. The task dictionary is given as the ``task`` argument. enqueued. The task dictionary is given as the ``task`` argument.
After spawning a worker process
"""""""""""""""""""""""""""""""
The ``django_q.signals.post_spawn`` signal is emitted after a worker process has
spawned. The process name is given as the ``proc_name`` argument (string).
Before executing a task Before executing a task
""""""""""""""""""""""" """""""""""""""""""""""
@@ -37,7 +43,7 @@ Connecting to a Django Q2 signal is done the same as any other Django
signal:: signal::
from django.dispatch import receiver from django.dispatch import receiver
from django_q.signals import pre_enqueue, pre_execute, post_execute from django_q.signals import pre_enqueue, pre_execute, post_execute, post_spawn
@receiver(pre_enqueue) @receiver(pre_enqueue)
def my_pre_enqueue_callback(sender, task, **kwargs): def my_pre_enqueue_callback(sender, task, **kwargs):
@@ -51,4 +57,8 @@ signal::
def my_post_execute_callback(sender, task, **kwargs): def my_post_execute_callback(sender, task, **kwargs):
print(f"Task {task['name']} was executed with result {task['result']}") print(f"Task {task['name']} was executed with result {task['result']}")
@receiver(post_spawn)
def my_post_spawn_callback(sender, proc_name, **kwargs):
print(f"Process {proc_name} has spawned")

View File

@@ -1,6 +1,6 @@
[tool.poetry] [tool.poetry]
name = "django-q2" name = "django-q2"
version = "1.5.1" version = "1.5.2"
packages = [ packages = [
{ include = "django_q" }, { include = "django_q" },
] ]