AkshayB
AkshayB

Reputation: 55

Can we retrieve the parameters originally passed in scheduler.Schedule() (Like Args) in RQ scheduler?

What i want:

I am trying to retrieve the parameters i passed to my job in rq scheduler while scheduling like: args passed, Function name, and other things

What i have already tried:

list_of_jobs=scheduler.get_jobs()
# print("jobs lsit",list_of_jobs)

for job in list_of_jobs:
    print(job.args)

Error Shown

Traceback (most recent call last):
 
 
    raise AppRegistryNotReady("Models aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Models aren't loaded yet.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  ile "/home/munz/.local/lib/python3.7/site-packages/rq/job.py", line 266, in _deserialize_data
    raise DeserializationError() from e
rq.exceptions.DeserializationError

Upvotes: 0

Views: 396

Answers (2)

mj_
mj_

Reputation: 6447

I'm not sure the accepted answer is correct. You can re-queue a job so somehow the arguments have to be persisted somewhere.

I grabbed a Job object I had and noticed that it has a property called data. This is a pickled byte array so pickle.loads(job.data) gave me back a dictionary like so:

('ph.mod.tasks.foo', None, (), {})

Upvotes: 0

AkshayB
AkshayB

Reputation: 55

Answer to this is NO IT CANNOT BE DONE

Any job related parameters can only be retrieved using job ID so i suggest to keep the job ID stored for all your jobs else you will in darkness about their original parameters (when you set it)

Upvotes: 0

Related Questions