This file is indexed.

/usr/share/doc/python-gearman/html/1to2.html is in python-gearman 2.0.2-2build1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>2. Transitioning from python-gearman 1.x to 2.0.0 &mdash; python-gearman v2.0.2 documentation</title>
    <link rel="stylesheet" href="_static/default.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '',
        VERSION:     '2.0.2',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/underscore.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <link rel="top" title="python-gearman v2.0.2 documentation" href="index.html" />
    <link rel="next" title="3. Design document" href="architecture.html" />
    <link rel="prev" title="1.4. gearman.job — Gearman job definitions" href="job.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="architecture.html" title="3. Design document"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="job.html" title="1.4. gearman.job — Gearman job definitions"
             accesskey="P">previous</a> |</li>
        <li><a href="index.html">python-gearman v2.0.2 documentation</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="transitioning-from-python-gearman-1-x-to-2-0-0">
<h1>2. Transitioning from python-gearman 1.x to 2.0.0<a class="headerlink" href="#transitioning-from-python-gearman-1-x-to-2-0-0" title="Permalink to this headline"></a></h1>
<div class="section" id="client-single-task">
<h2>2.1. Client (single task)<a class="headerlink" href="#client-single-task" title="Permalink to this headline"></a></h2>
<div class="highlight-python"><div class="highlight"><pre><span class="c"># python-gearman 1.x</span>
<span class="n">old_client</span> <span class="o">=</span> <span class="n">gearman</span><span class="o">.</span><span class="n">GearmanClient</span><span class="p">([</span><span class="s">&#39;localhost:4730&#39;</span><span class="p">])</span>
<span class="n">old_result</span> <span class="o">=</span> <span class="n">old_client</span><span class="o">.</span><span class="n">do_task</span><span class="p">(</span><span class="n">Task</span><span class="p">(</span><span class="s">&quot;echo&quot;</span><span class="p">,</span> <span class="s">&quot;foo&quot;</span><span class="p">))</span>


<span class="c"># python-gearman 2.x</span>
<span class="n">new_client</span> <span class="o">=</span> <span class="n">gearman</span><span class="o">.</span><span class="n">GearmanClient</span><span class="p">([</span><span class="s">&#39;localhost:4730&#39;</span><span class="p">])</span>
<span class="n">current_request</span> <span class="o">=</span> <span class="n">new_client</span><span class="o">.</span><span class="n">submit_job</span><span class="p">(</span><span class="s">&#39;echo&#39;</span><span class="p">,</span> <span class="s">&#39;foo&#39;</span><span class="p">)</span>
<span class="n">new_result</span> <span class="o">=</span> <span class="n">current_request</span><span class="o">.</span><span class="n">result</span>
</pre></div>
</div>
</div>
<div class="section" id="client-multiple-tasks">
<h2>2.2. Client (multiple tasks)<a class="headerlink" href="#client-multiple-tasks" title="Permalink to this headline"></a></h2>
<div class="highlight-python"><div class="highlight"><pre><span class="c"># python-gearman 1.x</span>
<span class="n">old_client</span> <span class="o">=</span> <span class="n">gearman</span><span class="o">.</span><span class="n">GearmanClient</span><span class="p">([</span><span class="s">&#39;localhost:4730&#39;</span><span class="p">])</span>
<span class="n">ts</span> <span class="o">=</span> <span class="n">Taskset</span><span class="p">([</span>
    <span class="n">Task</span><span class="p">(</span><span class="n">func</span><span class="o">=</span><span class="s">&quot;echo&quot;</span><span class="p">,</span> <span class="n">arg</span><span class="o">=</span><span class="s">&quot;foo&quot;</span><span class="p">),</span>
    <span class="n">Task</span><span class="p">(</span><span class="n">func</span><span class="o">=</span><span class="s">&quot;echo&quot;</span><span class="p">,</span> <span class="n">arg</span><span class="o">=</span><span class="s">&quot;bar&quot;</span><span class="p">),</span>
<span class="p">])</span>
<span class="n">old_client</span><span class="o">.</span><span class="n">do_taskset</span><span class="p">(</span><span class="n">ts</span><span class="p">)</span>
<span class="k">for</span> <span class="n">task</span> <span class="ow">in</span> <span class="n">ts</span><span class="o">.</span><span class="n">values</span><span class="p">():</span>
    <span class="k">assert</span> <span class="n">task</span><span class="o">.</span><span class="n">result</span> <span class="o">==</span> <span class="n">task</span><span class="o">.</span><span class="n">arg</span>


<span class="c"># python-gearman 2.x</span>
<span class="n">new_client</span> <span class="o">=</span> <span class="n">gearman</span><span class="o">.</span><span class="n">GearmanClient</span><span class="p">([</span><span class="s">&#39;localhost:4730&#39;</span><span class="p">])</span>
<span class="n">new_jobs</span> <span class="o">=</span> <span class="p">[</span>
    <span class="nb">dict</span><span class="p">(</span><span class="n">task</span><span class="o">=</span><span class="s">&#39;echo&#39;</span><span class="p">,</span> <span class="n">data</span><span class="o">=</span><span class="s">&#39;foo&#39;</span><span class="p">),</span>
    <span class="nb">dict</span><span class="p">(</span><span class="n">task</span><span class="o">=</span><span class="s">&#39;echo&#39;</span><span class="p">,</span> <span class="n">data</span><span class="o">=</span><span class="s">&#39;bar&#39;</span><span class="p">),</span>
<span class="p">]</span>

<span class="n">completed_requests</span> <span class="o">=</span> <span class="n">new_client</span><span class="o">.</span><span class="n">submit_multiple_jobs</span><span class="p">(</span><span class="n">new_jobs</span><span class="p">)</span>
<span class="k">for</span> <span class="n">current_request</span> <span class="ow">in</span> <span class="n">completed_requests</span><span class="p">:</span>
    <span class="k">assert</span> <span class="n">current_request</span><span class="o">.</span><span class="n">result</span> <span class="o">==</span> <span class="n">current_request</span><span class="o">.</span><span class="n">job</span><span class="o">.</span><span class="n">data</span>
</pre></div>
</div>
</div>
<div class="section" id="worker">
<h2>2.3. Worker<a class="headerlink" href="#worker" title="Permalink to this headline"></a></h2>
<div class="highlight-python"><div class="highlight"><pre><span class="c"># python-gearman 1.x</span>
<span class="k">class</span> <span class="nc">WorkerHook</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
    <span class="k">def</span> <span class="nf">start</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">current_job</span><span class="p">):</span>
        <span class="k">print</span> <span class="s">&quot;Job started&quot;</span>

    <span class="k">def</span> <span class="nf">fail</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">current_job</span><span class="p">,</span> <span class="n">exc_info</span><span class="p">):</span>
        <span class="k">print</span> <span class="s">&quot;Job failed, can&#39;t stop last gasp GEARMAN_COMMAND_WORK_FAIL&quot;</span>

    <span class="k">def</span> <span class="nf">complete</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">current_job</span><span class="p">,</span> <span class="n">result</span><span class="p">):</span>
        <span class="k">print</span> <span class="s">&quot;Job complete, can&#39;t stop last gasp GEARMAN_COMMAND_WORK_COMPLETE&quot;</span>

<span class="k">def</span> <span class="nf">callback_fxn</span><span class="p">(</span><span class="n">idle</span><span class="p">,</span> <span class="n">last_job_time</span><span class="p">):</span>
    <span class="k">return</span> <span class="bp">False</span>

<span class="n">old_worker</span> <span class="o">=</span> <span class="n">gearman</span><span class="o">.</span><span class="n">GearmanWorker</span><span class="p">([</span><span class="s">&#39;localhost:4730&#39;</span><span class="p">])</span>
<span class="n">old_worker</span><span class="o">.</span><span class="n">register_function</span><span class="p">(</span><span class="s">&quot;echo&quot;</span><span class="p">,</span> <span class="k">lambda</span> <span class="n">job</span><span class="p">:</span><span class="n">job</span><span class="o">.</span><span class="n">arg</span><span class="p">)</span>
<span class="n">old_worker</span><span class="o">.</span><span class="n">work</span><span class="p">(</span><span class="n">stop_if</span><span class="o">=</span><span class="n">callback_fxn</span><span class="p">,</span> <span class="n">hooks</span><span class="o">=</span><span class="n">WorkerHook</span><span class="p">())</span>


<span class="c"># python-gearman 2.x</span>
<span class="k">class</span> <span class="nc">CustomGearmanWorker</span><span class="p">(</span><span class="n">gearman</span><span class="o">.</span><span class="n">GearmanWorker</span><span class="p">):</span>
    <span class="k">def</span> <span class="nf">on_job_execute</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">current_job</span><span class="p">):</span>
        <span class="k">print</span> <span class="s">&quot;Job started&quot;</span>
        <span class="k">return</span> <span class="nb">super</span><span class="p">(</span><span class="n">CustomGearmanWorker</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">on_job_execute</span><span class="p">(</span><span class="n">current_job</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">on_job_exception</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">current_job</span><span class="p">,</span> <span class="n">exc_info</span><span class="p">):</span>
        <span class="k">print</span> <span class="s">&quot;Job failed, CAN stop last gasp GEARMAN_COMMAND_WORK_FAIL&quot;</span>
        <span class="k">return</span> <span class="nb">super</span><span class="p">(</span><span class="n">CustomGearmanWorker</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">on_job_exception</span><span class="p">(</span><span class="n">current_job</span><span class="p">,</span> <span class="n">exc_info</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">on_job_complete</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">current_job</span><span class="p">,</span> <span class="n">job_result</span><span class="p">):</span>
        <span class="k">print</span> <span class="s">&quot;Job failed, CAN stop last gasp GEARMAN_COMMAND_WORK_FAIL&quot;</span>
        <span class="k">return</span> <span class="nb">super</span><span class="p">(</span><span class="n">CustomGearmanWorker</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">send_job_complete</span><span class="p">(</span><span class="n">current_job</span><span class="p">,</span> <span class="n">job_result</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">after_poll</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">any_activity</span><span class="p">):</span>
        <span class="c"># Return True if you want to continue polling, replaces callback_fxn</span>
        <span class="k">return</span> <span class="bp">True</span>

<span class="k">def</span> <span class="nf">task_callback</span><span class="p">(</span><span class="n">gearman_worker</span><span class="p">,</span> <span class="n">job</span><span class="p">):</span>
    <span class="k">return</span> <span class="n">job</span><span class="o">.</span><span class="n">data</span>

<span class="n">new_worker</span> <span class="o">=</span> <span class="n">CustomGearmanWorker</span><span class="p">([</span><span class="s">&#39;localhost:4730&#39;</span><span class="p">])</span>
<span class="n">new_worker</span><span class="o">.</span><span class="n">register_task</span><span class="p">(</span><span class="s">&quot;echo&quot;</span><span class="p">,</span> <span class="n">task_callback</span><span class="p">)</span>
<span class="n">new_worker</span><span class="o">.</span><span class="n">work</span><span class="p">()</span>
</pre></div>
</div>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
  <h3><a href="index.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">2. Transitioning from python-gearman 1.x to 2.0.0</a><ul>
<li><a class="reference internal" href="#client-single-task">2.1. Client (single task)</a></li>
<li><a class="reference internal" href="#client-multiple-tasks">2.2. Client (multiple tasks)</a></li>
<li><a class="reference internal" href="#worker">2.3. Worker</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="job.html"
                        title="previous chapter">1.4. <tt class="docutils literal"><span class="pre">gearman.job</span></tt> &#8212; Gearman job definitions</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="architecture.html"
                        title="next chapter">3. Design document</a></p>
  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="_sources/1to2.txt"
           rel="nofollow">Show Source</a></li>
  </ul>
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="architecture.html" title="3. Design document"
             >next</a> |</li>
        <li class="right" >
          <a href="job.html" title="1.4. gearman.job — Gearman job definitions"
             >previous</a> |</li>
        <li><a href="index.html">python-gearman v2.0.2 documentation</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2010, Matthew Tai.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.8.
    </div>
  </body>
</html>