You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<p>SomeClass can be any python class with <em>perform</em> method and a <em>queue</em>
70
-
attribute on it.</p>
71
-
<dlclass="method">
72
-
<dtid="pyres.ResQ.enqueue">
73
-
<ttclass="descname">enqueue</tt><big>(</big><em>klass</em>, <em>*args</em><big>)</big><aclass="headerlink" href="#pyres.ResQ.enqueue" title="Permalink to this definition">¶</a></dt>
74
-
<dd>Enqueue a job into a specific queue. Make sure the class you are passing
75
-
has <strong>queue</strong> attribute and a <strong>perform</strong> method on it.</dd></dl>
76
-
77
-
<dlclass="method">
78
-
<dtid="pyres.ResQ.info">
79
-
<ttclass="descname">info</tt><big>(</big><big>)</big><aclass="headerlink" href="#pyres.ResQ.info" title="Permalink to this definition">¶</a></dt>
80
-
<dd>Returns a dictionary of the current status of the pending jobs,
81
-
processed, no. of queues, no. of workers, no. of failed jobs.</dd></dl>
82
-
83
-
</dd></dl>
84
-
85
-
</div>
86
-
<divclass="section" id="job-classes">
87
-
<h1>Job Classes<aclass="headerlink" href="#job-classes" title="Permalink to this headline">¶</a></h1>
88
-
<dlclass="class">
89
-
<dtid="pyres.job.Job">
90
-
<emclass="property">
91
-
class </em><ttclass="descclassname">pyres.job.</tt><ttclass="descname">Job</tt><big>(</big><em>queue</em>, <em>payload</em>, <em>resq</em>, <em>worker=None</em><big>)</big><aclass="headerlink" href="#pyres.job.Job" title="Permalink to this definition">¶</a></dt>
92
-
<dd><p>Every job on the ResQ is a <em>Job</em> object which has queue and payload(all the
93
-
args data and when its created etc).</p>
94
-
<dlclass="method">
95
-
<dtid="pyres.job.Job.perform">
96
-
<ttclass="descname">perform</tt><big>(</big><big>)</big><aclass="headerlink" href="#pyres.job.Job.perform" title="Permalink to this definition">¶</a></dt>
97
-
<dd>This method converts payload into args and calls the <strong>perform</strong> method
98
-
on the payload class.</dd></dl>
99
-
100
-
<dlclass="classmethod">
101
-
<dtid="pyres.job.Job.reserve">
102
-
<emclass="property">
103
-
classmethod </em><ttclass="descname">reserve</tt><big>(</big><em>queue</em>, <em>res</em>, <em>worker=None</em><big>)</big><aclass="headerlink" href="#pyres.job.Job.reserve" title="Permalink to this definition">¶</a></dt>
104
-
<dd>Reserve a job on the queue. In simple marking this job so that other worker
105
-
will not pick it up</dd></dl>
106
-
107
-
</dd></dl>
108
-
109
-
</div>
110
-
<divclass="section" id="worker-classes">
111
-
<h1>Worker Classes<aclass="headerlink" href="#worker-classes" title="Permalink to this headline">¶</a></h1>
112
-
<dlclass="class">
113
-
<dtid="pyres.worker.Worker">
114
-
<emclass="property">
115
-
class </em><ttclass="descclassname">pyres.worker.</tt><ttclass="descname">Worker</tt><big>(</big><em>queues=</em><spanclass="optional">[</span><spanclass="optional">]</span>, <em>server='localhost:6379'</em>, <em>password=None</em><big>)</big><aclass="headerlink" href="#pyres.worker.Worker" title="Permalink to this definition">¶</a></dt>
116
-
<dd><p>Defines a worker. The <em>pyres_worker</em> script instantiates this Worker class and
117
-
pass a comma seperate list of queues to listen on.:</p>
<ttclass="descname">validate_queues</tt><big>(</big><big>)</big><aclass="headerlink" href="#pyres.worker.Worker.validate_queues" title="Permalink to this definition">¶</a></dt>
125
-
<dd>Checks if a worker is given atleast one queue to work on.</dd></dl>
126
-
127
-
<dlclass="method">
128
-
<dtid="pyres.worker.Worker.work">
129
-
<ttclass="descname">work</tt><big>(</big><em>interval=5</em><big>)</big><aclass="headerlink" href="#pyres.worker.Worker.work" title="Permalink to this definition">¶</a></dt>
130
-
<dd><p>Invoked by run() method. work() listens on a list of queues and sleeps
131
-
for <em>interval</em> time.</p>
132
-
<p>default – 5 secs</p>
133
-
<p>Whenever a worker finds a job on the queue it first calls <ttclass="docutils literal"><spanclass="pre">reserve</span></tt> on
134
-
that job to make sure other worker won’t run it, then <em>Forks</em> itself to
135
-
work on that job.</p>
136
-
<p>Finally process() method actually processes the job.</p>
0 commit comments