18 Commits

Author SHA1 Message Date
GDay
7add68f770 Release v1.6.2 2024-03-05 16:46:08 +01:00
Stan Triepels
782b1de60d Allow different broker on chain (#156) 2024-03-02 22:45:40 +01:00
Josh Thomas
88430c9014 Fix formatting issues in README.rst (#159) 2024-02-20 18:04:46 +01:00
Stan Triepels
6265a54008 Update docs to add cluster option to the async_task (#157) 2024-02-18 04:00:07 +01:00
Stan Triepels
1b638e5802 Update release/test dependencies (#147)
* Update release dependencies

* Update test.yml
2023-12-14 16:06:34 +01:00
Tobias Menzel
13a382cca2 Fix for Negative Repeat Count in Scheduler (#101) (#146)
* Comment out decrement of s.repeats in scheduler to fix negative repeat count issue

* Fix repeat count handling in scheduler

- Reset `repeats` to -1 for values less than -1
- Decrement `repeats` by 1 if it's greater than 0
2023-12-14 14:44:07 +01:00
Stan Triepels
098aa66a2d Update django.po (#138) 2023-11-04 19:52:43 +01:00
Stan Triepels
b3f494571f Use importerror for b62_decode and avoid deprecation notification (#134) 2023-10-26 14:29:13 +02:00
Patrycja
503127233f Specify build system in pyproject.toml (#131)
Otherwise, trying to build the project with a tool like gpep517 or build
results in using the setuptools legacy backend instead
2023-10-19 22:05:16 +02:00
GDay
e3be22ac63 Release v1.6.1 2023-10-13 14:15:58 +02:00
Stan Triepels
0aaeb8d35d Fix strict versions for python/django - poetry install error (#130) 2023-10-13 14:13:22 +02:00
GDay
750c654940 Release v1.6.0 2023-10-13 00:59:42 +02:00
Stan Triepels
1d2a6059db Add support for Django 5 (#120) 2023-10-12 22:44:19 +02:00
Stan Triepels
54ab399758 Fix for "apps not ready" in Windows and Mac (#116) 2023-10-09 22:04:32 +02:00
Grayknife
bc50219141 Update broken MongoClient link in Docs (#127) 2023-10-07 22:15:49 +02:00
Grayknife
939d0ebef1 Fix German Translation Typo (#124) 2023-09-30 13:28:42 +02:00
Jrog
68af2ae13e Update Add-ons install command in install.rst (#115) 2023-09-14 14:37:12 +02:00
Dustin Blanchard
960f72a1d0 DOCS: Correct health check import in examples.rst (#110)
* Correct health check import in examples.rst

* Update monitor.rst

---------

Co-authored-by: Stan Triepels <1939656+GDay@users.noreply.github.com>
2023-09-05 17:05:47 +02:00
25 changed files with 1056 additions and 903 deletions

View File

@@ -11,15 +11,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: 3.8
python-version: 3.11
- name: Install dependencies
run: |
sudo apt-get update

View File

@@ -11,8 +11,25 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ "3.8", "3.9", "3.10", "3.11" ]
django: [ "3.2", "4.1", "4.2" ]
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12.0-rc.3" ]
django: [ "3.2", "4.1", "4.2", "5.0a1"]
exclude:
# django 5.0 does not support 3.8 and 3.9
- python-version: "3.8"
django: "5.0a1"
- python-version: "3.9"
django: "5.0a1"
# django 4.2 does not support 3.12
- python-version: "3.12.0-rc.3"
django: "4.2"
# django 4.1 does not support 3.12
- python-version: "3.12.0-rc.3"
django: "4.1"
# django 3.2 does not support 3.11 and 3.12
- python-version: "3.11"
django: "3.2"
- python-version: "3.12.0-rc.3"
django: "3.2"
services:
disque:
@@ -39,16 +56,16 @@ jobs:
- 6379:6379
options: --entrypoint redis-server
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies with Django ${{ matrix.django }}
run: |
python -m pip install --upgrade pip
pip install poetry
poetry add "django==${{ matrix.django }}"
poetry add "django==${{ matrix.django }}" --python=${{ matrix.python-version }}
poetry install -E testing
- name: Run Tests
run: |
@@ -68,7 +85,7 @@ jobs:
finish:
needs: test
runs-on: ubuntu-latest
container: python:3-slim
container: python:3.11-bookworm
steps:
- name: Upload to coveralls
run: |

View File

@@ -1,6 +1,34 @@
# Changelog
## [Unreleased](https://github.com/GDay/django-q2/tree/HEAD)
## [v1.6.2](https://github.com/django-q2/django-q2/tree/v1.6.2) (2024-03-05)
**Merged pull requests:**
- Allow different broker on chain https://github.com/django-q2/django-q2/pull/156
- Fix formatting issues in README.rst https://github.com/django-q2/django-q2/pull/159
- Update docs to add cluster option to the async_task https://github.com/django-q2/django-q2/pull/157
- Update release/test dependencies https://github.com/django-q2/django-q2/pull/147
- Fix for Negative Repeat Count in Scheduler https://github.com/django-q2/django-q2/pull/146
- Update django.po https://github.com/django-q2/django-q2/pull/138
- Use importerror for b62_decode and avoid deprecation notification https://github.com/django-q2/django-q2/pull/134
- Specify build system in pyproject.toml https://github.com/django-q2/django-q2/pull/131
## [v1.6.1](https://github.com/django-q2/django-q2/tree/v1.6.1) (2023-10-13)
**Merged pull requests:**
- Fix strict versions for python/django https://github.com/django-q2/django-q2/pull/130
## [v1.6.0](https://github.com/django-q2/django-q2/tree/v1.6.0) (2023-10-12)
**Merged pull requests:**
- Add support for Django 5 and python 12 https://github.com/django-q2/django-q2/pull/120
- Fix for "apps not ready" in Windows and Mac https://github.com/django-q2/django-q2/pull/116
- Update broken MongoClient link in Docs https://github.com/django-q2/django-q2/pull/127
- Fix German Translation Typo https://github.com/django-q2/django-q2/pull/124
- Update Add-ons install command in install.rst https://github.com/django-q2/django-q2/pull/115
- DOCS: Correct health check import in examples.rst https://github.com/django-q2/django-q2/pull/110
## [v1.5.5](https://github.com/django-q2/django-q2/tree/v1.5.5) (2023-09-01)

View File

@@ -3,9 +3,7 @@ A multiprocessing distributed task queue for Django
|image0| |image1| |docs| |downloads|
::
Django Q2 is a fork of Django Q. Big thanks to Ilan Steemers for starting this project. Unfortunately, development has stalled since June 2021. Django Q2 is the new updated version of Django Q, with dependencies updates, docs updates and several bug fixes. Original repository: https://github.com/Koed00/django-q
Django Q2 is a fork of Django Q. Big thanks to Ilan Steemers for starting this project. Unfortunately, development has stalled since June 2021. Django Q2 is the new updated version of Django Q, with dependencies updates, docs updates and several bug fixes. Original repository: https://github.com/Koed00/django-q
Features
~~~~~~~~
@@ -27,7 +25,7 @@ Changes compared to the original Django-Q:
- Dropped support for Disque (hasn't been updated in a long time)
- Dropped Redis, Arrow and Blessed dependencies
- Updated all current dependencies
- Added tests for Django 4.x
- Added tests for Django 4.x and 5.x
- Added Turkish language
- Improved admin area
- Fixed a lot of issues
@@ -40,7 +38,7 @@ Requirements
- `Django <https://www.djangoproject.com>`__ > = 3.2
- `Django-picklefield <https://github.com/gintas/django-picklefield>`__
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.
Tested with: Python 3.8, 3.9, 3.10, 3.11 and 3.12. Works with Django 3.2.X, 4.1.X, 4.2.X and 5.0.X
Brokers
~~~~~~~
@@ -73,7 +71,6 @@ Installation
Read the full documentation at `https://django-q2.readthedocs.org <https://django-q2.readthedocs.org>`__
Configuration
~~~~~~~~~~~~~
@@ -104,10 +101,7 @@ For full configuration options, see the `configuration documentation <https://dj
Management Commands
~~~~~~~~~~~~~~~~~~~
::
For the management commands to work, you will need to install Blessed: <https://github.com/jquast/blessed>
For the management commands to work, you will need to install Blessed: <https://github.com/jquast/blessed>
Start a cluster with::
@@ -159,7 +153,6 @@ Use `async_task` from your code to quickly offload tasks:
For more info see `Tasks <https://django-q2.readthedocs.org/en/latest/tasks.html>`__
Schedule
~~~~~~~~
@@ -204,7 +197,6 @@ Admin page or directly from your code:
For more info check the `Schedules <https://django-q2.readthedocs.org/en/latest/schedules.html>`__ documentation.
Testing
~~~~~~~

View File

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

View File

@@ -9,11 +9,6 @@ from time import sleep
from django import core, db
from django.apps.registry import apps
from django_q.monitor import monitor
from django_q.pusher import pusher
from django_q.scheduler import scheduler
from django_q.worker import worker
try:
apps.check_apps_ready()
except core.exceptions.AppRegistryNotReady:
@@ -25,16 +20,15 @@ from django.utils import timezone
from django.utils.translation import gettext_lazy as _
# Local
import django_q.tasks
from django_q.brokers import Broker, get_broker
from django_q.conf import Conf, get_ppid, logger, psutil, setproctitle
from django_q.humanhash import humanize
from django_q.models import Schedule, Success, Task
from django_q.monitor import monitor
from django_q.pusher import pusher
from django_q.queues import Queue
from django_q.signing import BadSignature, SignedPackage
from django_q.scheduler import scheduler
from django_q.status import Stat, Status
from .utils import get_func_repr
from django_q.worker import worker
class Cluster:

View File

@@ -2,16 +2,19 @@ import datetime
import time
import zlib
import django
from django.core.signing import BadSignature, JSONSerializer, SignatureExpired
from django.core.signing import Signer as Sgnr
from django.core.signing import TimestampSigner as TsS
from django.core.signing import b64_decode, dumps
try:
from django.core.signing import base62
from django.core.signing import b62_decode
except ImportError:
# For django < 4.0
# fallback for django 3.x
from django.utils.baseconv import base62
b62_decode = base62.decode
from django.utils.crypto import constant_time_compare
from django.utils.encoding import force_bytes, force_str
@@ -76,7 +79,7 @@ class TimestampSigner(Signer, TsS):
"""
result = super(TimestampSigner, self).unsign(value)
value, timestamp = result.rsplit(self.sep, 1)
timestamp = base62.decode(timestamp)
timestamp = b62_decode(timestamp)
if max_age is not None:
if isinstance(max_age, datetime.timedelta):
max_age = max_age.total_seconds()

View File

@@ -318,7 +318,7 @@ msgstr "Anzahl Minuten für den Typ 'Minuten'"
#: models.py:205
msgid "Repeats"
msgstr "Wiederhohlungen"
msgstr "Wiederholungen"
#: models.py:205
msgid "n = n times, -1 = forever"

View File

@@ -303,7 +303,7 @@ msgstr "Bimestriel"
#: models.py:194
msgid "Quarterly"
msgstr "Tous les quart-dheure"
msgstr "Trimestriel"
#: models.py:195
msgid "Yearly"

View File

@@ -1,15 +1,23 @@
from multiprocessing.process import current_process
from multiprocessing.queues import Queue
from django import db
from django import core, db
from django.utils.translation import gettext_lazy as _
from django.apps.registry import apps
try:
apps.check_apps_ready()
except core.exceptions.AppRegistryNotReady:
import django
django.setup()
import django_q.tasks
from django_q.brokers import Broker, get_broker
from django_q.conf import Conf, logger, setproctitle
from django_q.models import Success, Task
from django_q.signals import post_execute
from django_q.signing import SignedPackage
from django_q.tasks import async_chain
from django_q.utils import close_old_django_connections, get_func_repr
try:
@@ -77,7 +85,7 @@ def save_task(task, broker: Broker):
return
# enqueues next in a chain
if task.get("chain", None):
django_q.tasks.async_chain(
async_chain(
task["chain"],
group=task["group"],
cached=task["cached"],
@@ -185,7 +193,7 @@ def save_cached(task, broker: Broker):
broker.cache.set(group_key, group_list, timeout)
# async_task next in a chain
if task.get("chain", None):
django_q.tasks.async_chain(
async_chain(
task["chain"],
group=group,
cached=task["cached"],

View File

@@ -3,7 +3,16 @@ from multiprocessing.process import current_process
from multiprocessing.queues import Queue
from time import sleep
from django import core
from django.utils.translation import gettext_lazy as _
from django.apps.registry import apps
try:
apps.check_apps_ready()
except core.exceptions.AppRegistryNotReady:
import django
django.setup()
from django_q.brokers import Broker, get_broker
from django_q.conf import Conf, logger

View File

@@ -1,15 +1,24 @@
import ast
from multiprocessing.process import current_process
from django import db
from django import core, db
from django.utils import timezone
from django.utils.translation import gettext_lazy as _
import django_q.tasks
from django.apps.registry import apps
try:
apps.check_apps_ready()
except core.exceptions.AppRegistryNotReady:
import django
django.setup()
from django_q.brokers import Broker, get_broker
from django_q.conf import Conf, logger
from django_q.humanhash import humanize
from django_q.models import Schedule
from django_q.tasks import async_task
from django_q.utils import close_old_django_connections, localtime
@@ -73,7 +82,15 @@ def scheduler(broker: Broker = None):
break
s.next_run = next_run
s.repeats += -1
# Little Fix for already broken numbers
if s.repeats < -1:
s.repeats = -1
# Check if the value is not zero
if s.repeats > 0:
s.repeats -= 1
# send it to the cluster; any cluster name is allowed in multi-queue scenarios
# because `broker_name` is confusing, using `cluster` name is recommended and takes precedence
q_options["cluster"] = s.cluster or q_options.get(
@@ -86,7 +103,7 @@ def scheduler(broker: Broker = None):
q_options["broker"] = broker
q_options["group"] = q_options.get("group", s.name or s.id)
kwargs["q_options"] = q_options
s.task = django_q.tasks.async_task(s.func, *args, **kwargs)
s.task = async_task(s.func, *args, **kwargs)
# log it
if not s.task:
logger.error(

View File

@@ -569,10 +569,10 @@ class Chain:
A sequential chain of tasks
"""
def __init__(self, chain=None, group=None, cached=Conf.CACHED, sync=Conf.SYNC):
def __init__(self, chain=None, group=None, cached=Conf.CACHED, sync=Conf.SYNC, broker=None):
self.chain = chain or []
self.group = group or ""
self.broker = get_broker()
self.broker = broker or get_broker()
self.cached = cached
self.sync = sync
self.started = False

View File

@@ -60,7 +60,7 @@ def get_func_repr(func):
def localtime(value=None) -> datetime:
"""Override for timezone.localtime to deal with naive times and local times"""
if settings.USE_TZ:
if django.VERSION >= (4, 0) and settings.USE_DEPRECATED_PYTZ:
if django.VERSION >= (4, 0) and getattr(settings, "USE_DEPRECATED_PYTZ", False):
import pytz
convert_to_tz = pytz.timezone(Conf.TIME_ZONE)

View File

@@ -4,8 +4,17 @@ from multiprocessing import Value
from multiprocessing.process import current_process
from multiprocessing.queues import Queue
from django import core
from django.utils import timezone
from django.utils.translation import gettext_lazy as _
from django.apps.registry import apps
try:
apps.check_apps_ready()
except core.exceptions.AppRegistryNotReady:
import django
django.setup()
from django_q.conf import Conf, error_reporter, logger, resource, setproctitle
from django_q.signals import post_spawn, pre_execute

View File

@@ -49,8 +49,9 @@ Reference
:param str group: an optional group name.
:param bool cached: run this against the cache backend
:param bool sync: execute this inline instead of asynchronous
:param broker: an optional broker instance
.. py:class:: Chain(chain=None, group=None, cached=Conf.CACHED, sync=Conf.SYNC)
.. py:class:: Chain(chain=None, group=None, cached=Conf.CACHED, sync=Conf.SYNC, broker=None)
A sequential chain of tasks. Acts as a convenient wrapper for :func:`async_chain`
You can pass the task chain at construction or you can append individual tasks before running them.
@@ -59,6 +60,8 @@ Reference
:param str group: an optional group name.
:param bool cached: run this against the cache backend
:param bool sync: execute this inline instead of asynchronous
:param bool sync: execute this inline instead of asynchronous
:param broker: an optional broker instance
.. py:method:: append(func, *args, **kwargs)

View File

@@ -73,9 +73,9 @@ author = "Ilan Steemers, Stan Triepels"
# built documents.
#
# The short X.Y version.
version = "1.5"
version = "1.6"
# The full version, including alpha/beta/rc tags.
release = "1.5.5"
release = "1.6.2"
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.

View File

@@ -348,7 +348,7 @@ To use MongoDB as a message broker you simply provide the connection information
}
}
The ``mongo`` dictionary can contain any of the parameters exposed by pymongo's `MongoClient <https://api.mongodb.org/python/current/api/pymongo/mongo_client.html#pymongo.mongo_client.MongoClient>`__
The ``mongo`` dictionary can contain any of the parameters exposed by pymongo's `MongoClient <https://pymongo.readthedocs.io/en/stable/api/pymongo/mongo_client.html#pymongo.mongo_client.MongoClient>`__
If you want to use a mongodb uri, you can supply it as the ``host`` parameter.
mongo_db

View File

@@ -328,7 +328,7 @@ Requires cache to be enabled. Save file in your Django project's root directory
# All django stuff has to come after the setup:
django.setup()
from django_q.monitor import Stat
from django_q.status import Stat
from django_q.conf import Conf
# Set host and port settings

View File

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

View File

@@ -43,12 +43,12 @@ Then migrate the database to get the latest tables/fields::
Requirements
------------
Django Q2 is tested for Python 3.8, 3.9, 3.10 and 3.11
Django Q2 is tested for Python 3.8, 3.9, 3.10, 3.11 and 3.12
- `Django <https://www.djangoproject.com>`__
Django Q2 aims to use as much of Django's standard offerings as possible.
The code is tested against Django versions `3.2.x`, `4.1.x` and`4.2.x`.
The code is tested against Django versions `3.2.x`, `4.1.x`, `4.2.x` and `5.0.x`.
- `Django-picklefield <https://github.com/gintas/django-picklefield>`__
@@ -115,11 +115,11 @@ Add-ons
-------
- `django-q-rollbar <https://github.com/danielwelch/django-q-rollbar>`__ is a Rollbar error reporter::
$ pip install django-q[rollbar]
$ pip install django-q2[rollbar]
- `django-q-sentry <https://github.com/danielwelch/django-q-sentry>`__ is a Sentry error reporter::
$ pip install django-q[sentry]
$ pip install django-q2[sentry]
- `django-q-email <https://github.com/joeyespo/django-q-email>`__ is a compatible Django email backend that will automatically async queue your emails.
@@ -145,7 +145,7 @@ Other known issues are:
Python
~~~~~~
Current tests are performed with 3.8, 3.9, 3.10 and 3.11
Current tests are performed with 3.8, 3.9, 3.10, 3.11 and 3.12
If you do encounter any regressions with earlier versions, please submit an issue on `github <https://github.com/GDay/django-q2>`__
Open-source packages
@@ -156,7 +156,7 @@ You can reference the `requirements <https://github.com/GDay/django-q2/blob/mast
Django
~~~~~~
We strive to be compatible with the last two major version of Django.
At the moment this means we support the 3.2.x, 4.1.x and 4.2.x releases.
At the moment this means we support the 3.2.x, 4.1.x, 4.2.x and 5.0.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.8
For this you can always use older releases, but they are no longer maintained.

View File

@@ -111,7 +111,7 @@ You can check the status of your clusters straight from your code with the :clas
.. code:: python
from django_q.monitor import Stat
from django_q.status import Stat
for stat in Stat.get_all():
print(stat.cluster_id, stat.status)

View File

@@ -75,6 +75,10 @@ broker
""""""
A broker instance, in case you want to control your own connections.
cluster
""""""
The name of the cluster. Only useful if you are using [alternative queues](https://django-q2.readthedocs.io/en/master/cluster.html#multiple-queues).
task_name
"""""""""
@@ -241,7 +245,7 @@ Reference
---------
.. py:function:: async_task(func, *args, hook=None, group=None, timeout=None,\
save=None, sync=False, cached=False, broker=None, q_options=None, **kwargs)
save=None, sync=False, cached=False, broker=None, cluster=None, q_options=None, **kwargs)
Puts a task in the cluster queue
@@ -255,6 +259,7 @@ Reference
:param bool sync: If set to True, async_task will simulate a task execution
:param cached: Output the result to the cache backend. Bool or timeout in seconds
:param broker: Optional broker connection from :func:`brokers.get_broker`
:param cluster: Optional cluster name if using alternative queues
:param dict q_options: Options dict, overrides option keywords
:param dict kwargs: Keyword arguments for the task function
:returns: The uuid of the task

1732
poetry.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,10 @@
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
[tool.poetry]
name = "django-q2"
version = "1.5.5"
version = "1.6.2"
packages = [
{ include = "django_q" },
]
@@ -30,6 +34,7 @@ classifiers = [
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Topic :: Internet :: WWW/HTTP',
'Topic :: System :: Distributed Computing',
'Topic :: Software Development :: Libraries :: Python Modules',
@@ -44,8 +49,8 @@ include = ['CHANGELOG.md']
[tool.poetry.dependencies]
python = ">=3.8, <4"
django = ">=3.2"
python = ">=3.8,<4"
django = { version = ">=3.2, <6", allow-prereleases = true}
django-picklefield = "^3.1"
blessed = { version = "^1.19.1", optional = true }
@@ -55,7 +60,7 @@ django-redis = { version = "^5.2.0", optional = true }
iron-mq = { version = "^0.9", optional = true }
boto3 = { version = "^1.24.92", optional = true }
pymongo = { version = "^4.2.0", optional = true }
croniter = { version = "^1.3.7", optional = true }
croniter = { version = "^2.0.1", optional = true }
django-q-rollbar = {version = ">=0.1", optional = true}
django-q-sentry = {version = ">=0.1", optional = true}
redis = {version = "^4.3.4", optional = true}