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

Bug fixes and improvements #34

Open
wants to merge 23 commits into
base: master
Choose a base branch
from

Conversation

tom-price
Copy link
Collaborator

OK, I'm re-implementing whats in PR #24 in two parts and this is the first step with the args+kwargs implementation built atop it to addresses issue #1. Here's an overview of the changes:

  • Changed
  • Version bumps on requirements for Django-RQ and rq-scheduler to account for RQ's version 1.0 and changes in Redis v3.
  • Tests now run using fakeredis and don't pollute your Redis instance.
  • Overall the tests have been restructured to take advantage of all of Factory's features. All past tests are still present and there are new ones bringing test coverage of models.py to 100%
  • Improvements on PR add seconds option to interval_units with tests #29 have been made adding seconds as an available interval unit following my comments. Driven by Issue Add seconds as a option RepeatableJob.UNITS  #28
  • Added prevention of the ability to set a repeatable job with a result_ttl shorter than the interval time. See the relevant important note here https://github.com/rq/rq-scheduler
  • Moved the enable disable checkboxes to a bulk enable / disable action for a simpler UX (not having both a "Go" and "Save" button. Change permissions are respected.
  • Added the ability to immediately run jobs as a bulk action based upon an improvement in UKTV's fork.

Matthew Egan and others added 15 commits October 10, 2018 12:05
Rejects when a job's interval is lower than a queue's interval.
Rejects when a job's interval is not a multiple of a queue's interval. This seemed to be the most restrictive approach from which things can be loosened up.
Added a settings parameter DJANGO_RQ_SCHEDULER_INTERVAL that can be used to change the schedular interval. Default is 60 matching DJANGO_RQ's default.
Renamed migration adding seconds to be more descriptive.
De-duped code and renamed QueueMixin, which had grown to be more than just that.
Fixed bug where user without delete permission would get error due to `del actions['delete_selected']` not existing in actions.
Delete, bulk enable, and bulk disable all give messages of their success status.
Made clear cron string times are in UTC.
With RQ geting a version 1.0 (from 0.13) several other packages had releases w. backwards incompatible changes (Django-RQ's v2.0 for example).
This update enforces these changes and bumps rq-rcheduler due to tests failing w. lower versions.
Also fixes an issue in this package causing a problem due to changes in redis v3.
Also changes Validation errors to better fit what's suggested in documentation.
Viewable to users with change permission.
Pulls timeout and result_ttl from job if present.
Does NOT decrement repeat count on repeatable job 🤔.
…rovements

# Conflicts:
#	scheduler/models.py
@CorneliusIV
Copy link

@tom-price Thanks Tom, I'm going to look this over today

@CorneliusIV CorneliusIV requested a review from jcarbaugh May 29, 2019 14:57
from model_utils import Choices
from model_utils.models import TimeStampedModel

RQ_SCHEDULER_INTERVAL = getattr(settings, "DJANGO_RQ_SCHEDULER_INTERVAL", 60)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is currently undocumented in the README. I've not done enough testing on the ramifications of changing this from the default interval of 60 set in Django RQ's get_scheduler function.
I have written checks that prevent saving jobs where the given job_interval either shorter than this interval or not a multiple of it (seemed the safest / most restrictive approach). I felt this was necessary as part of adding seconds as an interval_unit.

@@ -168,20 +207,36 @@ def interval_seconds(self):
}
return timedelta(**kwargs).total_seconds()

def _prevent_duplicate_runs(self):
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure this resolves issue #30
It sounds like the problem described is caused by there being remaining repeats with a scheduled time in the past. In my experience when this happens rq-scheduler starts the job right away essentially trying to catch up. The code below essentially steps forwards in time until there are no repeats left or it arrives at some new scheduled_time in the future that is the original scheduled_time + interval*n where n is the number of repeats it took to get there and subtracted from the repeats remaining.

@tom-price
Copy link
Collaborator Author

I've had to remove FakeRedis as an update broke its setup and I cannot figure it out.
This PR is a superset of changes in #29

@jcarbaugh jcarbaugh removed their request for review January 8, 2024 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants