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

fix: Add some checking for the Scheduler.enqueue_job method #318

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
10 changes: 6 additions & 4 deletions rq_scheduler/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,8 +418,10 @@ def enqueue_job(self, job):
use_local_timezone = job.meta.get('use_local_timezone', None)

# If job is a repeated job, decrement counter
if repeat:
job.meta['repeat'] = int(repeat) - 1
if repeat is not None:
repeat = int(repeat)
if repeat > 0:
job.meta['repeat'] = repeat - 1

queue = self.get_queue_for_job(job)
queue.enqueue_job(job, at_front=bool(job.enqueue_at_front))
Expand All @@ -428,14 +430,14 @@ def enqueue_job(self, job):
if interval:
# If this is a repeat job and counter has reached 0, don't repeat
if repeat is not None:
if job.meta['repeat'] == 0:
if job.meta['repeat'] <= 0:
return
self.connection.zadd(self.scheduled_jobs_key,
{job.id: to_unix(datetime.utcnow()) + int(interval)})
elif cron_string:
# If this is a repeat job and counter has reached 0, don't repeat
if repeat is not None:
if job.meta['repeat'] == 0:
if job.meta['repeat'] <= 0:
return
next_scheduled_time = get_next_scheduled_time(cron_string, use_local_timezone=use_local_timezone)
self.connection.zadd(self.scheduled_jobs_key,
Expand Down
Loading