Skip to content

Commit

Permalink
feat: Added explicit None type checking. Added check for negative rep…
Browse files Browse the repository at this point in the history
…eat value
  • Loading branch information
newmancu committed Nov 21, 2024
1 parent f7d5787 commit b1ad876
Showing 1 changed file with 6 additions and 4 deletions.
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

0 comments on commit b1ad876

Please sign in to comment.