240 Commits
Author SHA1 Message Date
David Macario d97b27901b Fix cluster requesting hardcoded unix-only fork context (#347) 2026-08-26 04:39:33 +02:00
Stan Triepels 9e576b85e6 Swap localstorage to ministack (#343) 2026-08-14 05:37:10 +02:00
Andy Galasso 480b77dfe4 AttributeError when start_event is None, and guard process faster stop (#305)
* AttributeError when start_event is None, and guard process faster stop

This commit has two related fixes that come into play when frequently
shutting down and restarting the cluster.

If a SIGINT or SIGTERM signal is received while the main process is
waiting for the sentinel process to set start_event, the signal
handler sets start_event to None, and the loop that polls start_event
will raise an unhandled AttributeError attempting to check
start_event.is_set().

The second issue is that the guard process sleeps for the guard cycle
interval in each iteration before checking the stop event, preventing
the guard cycle from terminating until the sleep completes. The
cluster can be made more responsive to a shutdown request by using
the event's wait(cycle) method rather than time.sleep(cycle) so the
process wakes immediately when the event is set.

The commit also fixes the case where the guard process sleeps for an
extra cycle when the cycle counter happens to have been reset to zero
on the loop iterations when the scheduler is called.

This fix helps in our environment where we are frequently stopping
and starting the cluster and where we have increased the guard
cycle setting to several seconds.

* Add sentinel premature death check while waiting for sentinel to start.

Suggested by github copilot [here](https://github.com/django-q2/django-q2/pull/305/changes#r3143964420)

* Add test case test_cluster_early_stop

Add a test case to validate stopping the cluster before the
sentinel has set the cluster's start_event.

The test deterministically triggers the AttributeError when
start_event is None (without the PR's fix in cluster.py).

As requested by copilot: https://github.com/django-q2/django-q2/pull/305#discussion_r3143964399

* Add test test_cluster_stop_responsive

Ensure that stopping the cluster is responsive and does not wait for a full
GUARD_CYCLE to stop the cluster.

As requested by copilot: https://github.com/django-q2/django-q2/pull/305/changes#r3143964414

* Address copilot review comments.

1. Do not raise RuntimeError if sentinel early exit was caused by
   SIGINT/SIGTERM stopping the cluster while waiting for the
   sentinel to start.
   Addresses https://github.com/django-q2/django-q2/pull/305#discussion_r3298618046

2. Ensure that the monkeypatched broker instance remains pickleable
   so the test_cluster_early_stop test will also work on platforms
   that use the spawn Process start method.
   Addresses https://github.com/django-q2/django-q2/pull/305#discussion_r3298618086

3. Do not allow the test_cluster_early_stop test to hang if the
   sentinel process or main test process terminates unexpectedly
   without setting the sentinel_event or test_event.
   Addresses https://github.com/django-q2/django-q2/pull/305#discussion_r3298618102
2026-05-26 00:07:53 +02:00
Nick YuanandClaude Opus 4.6 fab97463c2 Fix unbounded growth of Broker.set_stat cluster master list (#322)
Prune stale entries from the master list on new cluster registration
and only write the list when membership changes (with timeout=None).

Before this fix, set_stat was append-only — dead cluster keys accumulated
forever because the only cleanup path (get_stats) runs only from the
monitor UIs. On DatabaseCache backends this rewrote the growing pickled
list to Postgres on every heartbeat, producing measurable egress.

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-14 00:24:43 +02:00
Marcin Bachry 1b0f71a39b Fix BadSignature after the default Django cache expires (#311)
* async_iter: fix BadSignature after the default Django cache expires

* lint
2026-01-08 23:27:03 +01:00
prollings b51575a4b0 Add post_execute_in_worker signal (#309) 2025-12-10 16:54:14 +01:00
Salvo 'LtWorf' Tomaselli 09e65da5b3 Fix to make tests work with redis-py > 5 (#282) 2025-07-04 02:13:46 +02:00
Fernando Karchiloff a154fd658a Avoid creating task run on Scheduler creation (#268) 2025-03-12 23:31:00 +01:00
Anthony Hivert ddc1aa2de1 perf: avoid checking success tasks when save limit is disabled (#255)
- avoid extra queries when checking the count of success in db
2025-01-04 02:31:30 +01:00
Alberto fb23b6b825 Fix 'receive_message_wait_time_seconds' SQS broker management (#243)
* Fix 'receive_message_wait_time_seconds' SQS broker management

* Remove socket volume from localstack container
2024-11-03 15:04:35 +01:00
P-EB 35c911080b Fix BROKER_CLASS monkeypatch in test_brokers (#239) 2024-10-21 17:51:27 +02:00
P-EB 81058fc1cf Decrease the MAX_RSS set in test_cluster::test_max_rss (#240) 2024-10-21 17:50:30 +02:00
Stan Triepels d8cc0cc4f4 Fix not picking up result from falsy result (#107)
* Fix not picking up result from falsy result

* add test and docs

* typo
2023-09-01 02:36:15 +02:00
Stan Triepels 7fb7fca176 Move worker, scheduler, pusher and monitor to separate files (#100) 2023-07-02 02:47:05 +02:00
Scott PashleyandScott Pashley 23c06a38eb Rerun successful tasks (#99)
* Move logic that resubmits a task and then deletes the original into an action function that can be used for both failure and success resubmission.

* Use the resubmit_task action in the FailAdmin.

* Add the resubmit_task action to the TaskAdmin class.

* Update resubmit failure test to reflect using the new resubmit action.

* Add a test for resubmitting successful tasks.

---------

Co-authored-by: Scott Pashley
2023-06-23 23:05:04 +02:00
sinowoodandStan Triepels 52c04217e9 Multiple queue, multiple cluster in one site (#71)
* Support for multi-queue, multi-cluster configuration. API changes include:
  * Adding `cluster` to async_task() parameters and Task model
  * Adding argument --name to qcluster command
  * Necessary adjustments to Conf and Broker classes
  * Some admin improvements

* Add settings.Q_CLUSTER['ALT_CLUSTERS']: q_cluster config overrides for alternative clusters;
Add Conf.CLUSTER_NAME: separate usage from Conf.PREFIX;
QueueAdmin/OrmQ detail page enhanced: now displaying args/kwargs/q_options instead of encrypted payload.

* if `cluster` argument is not set (the default), async_task() and schedule() will be handled by the default cluster; Documentation update.

* Text cleanup

* Documentation update.

* Fix TIMEOUT setting in Windows for non-default cluster

---------

Co-authored-by: Stan Triepels <1939656+GDay@users.noreply.github.com>
2023-04-02 16:36:17 +02:00
msabatierandMarc Sabatier 650c3b1524 Fix use of database router for write queries and remove Conf.HAS_REPLICA (#61)
Co-authored-by: Marc Sabatier
2023-01-18 02:12:13 +01:00
msabatierandMarc Sabatier a013591de5 Add intended_date_kwarg field to Schedule (#62)
Co-authored-by: Marc Sabatier <marc.sabatier@eco-adapt.com>
2023-01-17 22:52:11 +01:00
Stan Triepels b66dfbd3af Fix DST timezone change (move from DST to normal jump) (#56) 2022-12-22 03:02:53 +01:00
Stan Triepels ce81059da8 Fix: allow both ZoneInfo and Pytz depending on django version (#55) 2022-12-21 03:42:38 +01:00
Stan Triepels e78e473be3 Fix: handling exceptions inside job function (#51) 2022-12-21 01:44:59 +01:00
Stan Triepels 4d454e4001 Fix: Daylight saving time issue with scheduler (#47) 2022-12-21 01:44:34 +01:00
Stan Triepels 3c0c32758d Chore: Flake8, isort and Black (#40) 2022-11-16 01:45:40 +01:00
Stan Triepels 542e04db54 Feat: Add biweekly and bimonthly and fix translations (#36) 2022-11-13 01:00:11 +01:00
Stan Triepels 0aac4e7b0d Fix unclear error when function is not called correctly (#19) 2022-10-20 17:24:17 +02:00
Stan Triepels c59f036158 Remove arrow dependency, update packages, set up testing with compose (#17) 2022-10-19 02:01:16 +02:00
Stan TriepelsandNoortheen Raja 9ace854290 Save limit per group/func/name (#12)
* feat: option to save tasks per group/func/name

* test: update tests for save limit

* fix: convert func when save-limit checking

when passed as function it needs to be converted to work

* Add warning if option is not valid

Co-authored-by: Noortheen Raja <jnoortheen@gmail.com>
2022-10-15 01:56:41 +02:00
Ilan Steemers f8cd136668 Post execute signal and tests (#580)
* adds post_execute signal and tests

* Updates signal docts

* Fixes typo in docs
2021-06-20 15:43:08 +02:00
Ilan Steemers 4df036dc9c Autofield (#574)
* Adds autofield default

* linting

* Updates packages
2021-06-10 15:42:21 +02:00
Ilan Steemers 15155c7a99 Build improvements (#569)
* Black linting

* Adding Black to dev dependencies and upping minimal python to 3.6.2 for compatibility

* Updating packages

* Removing pip-tools input and exporting requirements with poetry

* Deleting old setup files and test runner

* Trying 1.3.7

* Looser extras requirements to prevent conflicts

* Sorted imports with isort

* Added iSort to dev dependencies

* Fixes localtime for naive setups
2021-05-30 17:10:07 +02:00
Alexandre Xavier 71d4b726ea Feature/improves multiple databases support (#561)
* feat: adds docker local files to ignore

* feat: adds replica key to django q settings

* feat: adds multiple database routers testing utility

* feat: ensures scheduler works with multiple databases and replicas

* feat: adds docker image to support containerized development

* refactor: removes unnecessary import

* style: improves import styling

* docs: adds replica setting to configure documentation
2021-05-23 15:10:31 +02:00
Kenny Heinonen 728a1b85d0 Add "qmemory" command (#553)
* Add qmemory command

* Update README, add test

* Redesign qmemory

* Add optional argument to show each worker's memory usage

* Add --workers argument to test_qmemory
2021-05-14 13:44:40 +02:00
Dimitri 957f807598 Allow tasks to be scheduled on a specific cluster (#555)
* Allows schedule by cluster

* Update docs

* Add example in doc

* Fixes cluster field must be blank

* Adds cluster arg to schedule func

* Adds cluster field in list_display/filter for admin

* Uses Q filter to fetch schedule

* Fixes ref in doc

* Adds tests
2021-05-14 13:42:54 +02:00
Ilan Steemers de9ba04602 Fixes deprecated count method (#549)
* Replaces deprecated count with count_documents

* Uses new re_path instead of url()
2021-05-01 16:23:37 +02:00
Gouri JavedandJaved Gouri e205674d31 added long polling support (#506)
* added long pooling support for  sqs broker

* changed the parameter name

* added long polling support ,

introduce new parameter in broker sqs block
parameter for long polling is receive_message_wait_time_seconds

eg :
Q_CLUSTER = {
      'name': 'test-queue',
      'sqs': {
         'aws_region': AWS_S3_REGION_NAME,
         'aws_access_key_id': AWS_ACCESS_KEY_ID,
         'aws_secret_access_key': AWS_SECRET_ACCESS_KEY,
         'receive_message_wait_time_seconds':20
     }
}

* added receive_message_wait_time_seconds parameter in test_broker.py

Co-authored-by: Javed Gouri <you@example.com>
2021-03-21 12:04:16 +01:00
Ilan Steemers 7d03536e89 Migrate to Github Action CI (#507)
* Some small refactors

* Initial test script

* Fixes django matrix

* Trying to set up Disque

* Disque as a docker service

* lowercase action name

* Remove Travis

* Replaces Travis badge with Github actions badge

* Show django version in step

* Typo
2021-02-14 18:59:04 +01:00
Ilan Steemers d97e7d772f Merge pull request #479 from alx-sdv/bugs/model-str
Model.__unicode__() has no effect in Python 3.X
2020-10-20 14:01:40 +02:00
Daniel Trembath 3e8fc91d46 Change Django documentation URLs from v1.8 to v2.2
URLs were linking to a now unsupported version of Django. Django v2.2 is a LTS version, and also matches the documentation intersphinx_mapping in docs/conf.py.
2020-10-07 17:56:23 +11:00
alx-sdv 28197dc4fa Model.__unicode__() has no effect 2020-10-05 12:30:11 +03:00
Tim O'Meara 655f0aadb5 rename config var to max_retries, remove attempt_count form admin , add admin ui customization to docs 2020-08-13 11:58:00 -05:00
Tim O'Meara f26de929d6 adds tests 2020-08-11 11:48:23 -05:00
Ilan Steemers 0095a93b45 Adds max rss test 2020-07-08 22:52:07 +02:00
Ilan Steemers 572f810651 Adds max rss test 2020-07-08 22:47:35 +02:00
Ilan Steemers f223cfcb30 Removing value check 2020-07-01 14:25:51 +02:00
Ilan Steemers 532199fff3 Trigger cron validation 2020-07-01 14:18:04 +02:00
Ilan Steemers e6f82c5158 test model unicode 2020-06-30 22:00:31 +02:00
Ilan Steemers b17fd24682 Test for no nodes config 2020-06-30 21:35:57 +02:00
Ilan Steemers d46d08e94e Adds qinfo ids check 2020-06-30 21:19:15 +02:00
Ilan Steemers dda0c3c44d Test get_ids 2020-06-30 20:56:11 +02:00
Ilan Steemers 34293cfcad Test cron validator 2020-06-29 19:08:08 +02:00