0

I'm using Django-rq which has the functionality of Scheduling the jobs with specified interval.

https://github.com/rq/django-rq#support-for-rq-scheduler

task = scheduler.schedule(
    scheduled_time=datetime.utcnow(), # Time for first execution, in UTC timezone
    func=func,                     # Function to be queued
    args=[arg1, arg2],             # Arguments passed into function when executed
    kwargs={'foo': 'bar'},         # Keyword arguments passed into function when executed
    interval=60,                   # Time before the function is called again, in seconds
    repeat=None,                     # Repeat this number of times (None means repeat forever)
    meta={'foo': 'bar'}            # Arbitrary pickleable data on the job itself
)

print(task.id) ### JOB ID
5eedcd69-a318-4195-959f-eb6a404dec97
  • Now we have the JOB which executes for every 60 seconds and returns JOB ID for our scheduler, All I wanted to see the (number of times/count the number of times) the job has been executed.
example:

checking job `queue.fetch_job('5eedcd69-a318-4195-959f-eb6a404dec97').count` should return `5` times after 5 minutes
  • Is there any way to achieve it through the Django or RQ way?
Arbazz Hussain
  • 1,622
  • 2
  • 15
  • 41

1 Answers1

0

Not exactly. Rq-scheduler checks the current job's execution date and calculates when the next job will be executed at runtime. It doesn't store past and future jobs (only the next one in line).

Maybe the closest to this behavior is the "result_ttl" parameter, you can set a time to it and define how much time the job will remain listed after completion.