summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSelwin Ong <selwin.ong@gmail.com>2018-10-27 18:05:10 +0700
committerSelwin Ong <selwin.ong@gmail.com>2018-10-27 18:05:10 +0700
commit4d17d226f4339c0066db516b1e3fc07ff2a263d4 (patch)
treeaf564864e17cfc3a1d21fbe1f5da8294a5fd89a7
parenteaf598d73ce234791ee22ef82f7f095aece9f2a6 (diff)
downloadrq-4d17d226f4339c0066db516b1e3fc07ff2a263d4.tar.gz
Document Job.fetch() and job attributes.
-rw-r--r--docs/docs/jobs.md27
1 files changed, 25 insertions, 2 deletions
diff --git a/docs/docs/jobs.md b/docs/docs/jobs.md
index ec829ce..12b8aea 100644
--- a/docs/docs/jobs.md
+++ b/docs/docs/jobs.md
@@ -8,9 +8,32 @@ instance from within the job function itself. Or to store arbitrary data on
jobs.
-## Accessing the "current" job
+## Retrieving Job from Redis
+
+All job information is stored in Redis. You can inspect a job and its attributes
+by using `Job.fetch()`.
+
+{% highlight python %}
+from redis import Redis
+from rq.job import Job
-_New in version 0.3.3._
+connection = Redis()
+job = Job.fetch('my_job_id', connection=redis)
+print('Status: %s' $ job.get_status())
+{% endhighlight %}
+
+Some interesting job attributes include:
+* `job.status`
+* `job.func_name`
+* `job.args`
+* `job.kwargs`
+* `job.result`
+* `job.enqueued_at`
+* `job.started_at`
+* `job.ended_at`
+* `job.exc_info`
+
+## Accessing the "current" job
Since job functions are regular Python functions, you have to ask RQ for the
current job ID, if any. To do this, you can use: