Search 1.9 billion lines of Odoo code on GitHub

queue_job

Author: Camptocamp,ACSONE SA/NV,Odoo Community Association (OCA)
License: AGPL-3
Branch: 10.0
Repository: Tecnativa/queue
Dependencies: mail
Languages: Python (1522, 78.7%), XML (323, 16.7%), and reStructuredText (88, 4.6%)
Other branches: 14.0-fix-queue_job-dependency, and 14.0-fix-queue_job-readme
Other repositories: 001101/queue, 2FM/queue, ACCOMODATA-BVBA/queue, AITIC/queue, Alfa-90/queue, App247/queue, Callino/queue, Change2improve/queue, ChinaShrimp/queue, Comunitea/queue, DamonLiu0814/queue, Dhirendrasinh-SerpentCS/queue, Dhrupesh/queue, Digital5-Odoo/queue, ERPLibre/queue, ForgeFlow/queue, GSLabIt/queue, Gabinete-Digital/queue, Ingeos/queue, Jarsa/queue, KolushovAlexandr/queue, Leuan12/queue, MadsackMediaStore/queue, MathBenTech/queue, MediaJockey/queue, Miller-Media/connector, MjAbuz/queue, NachoAlesLopez/queue, NeatNerdPrime/queue, Numigi/queue, OCA-MUK/queue, OCA/queue, OpenAT/queue, PrenorSistemas/queue, RRRoger/queue, RSC-TECHNOLOGY-CI/queue, RealSolutionsLux/queue, SanteLibre/queue, SequarSrl/queue, SeuMarco/queue, SuperMeepBoy/queue, Syci-Consulting/queue, TDu/queue, TRESCLOUD/queue, Tatider/queue, Trust-Code/queue, VCLS-org/queue, Vauxoo/queue, VisiionSolucionesTecnologicas/queue, Vkuruganti/queue, acsone/queue, acysos/odoo-addons, akretion/queue, algiopensource/queue, alsor62/queue, altanmur/queue, amendoncabh/queue, anggadjava/queue, anhvu-sg/queue, apachesep/queue, apertoso/queue, apetbiz/queue, apineux/queue, atchuthan/queue, aurestic/queue, bishalgit/queue, blueoceandevops/queue, bmya/queue, bobslee/queue, boskowski/odoo_oca_queue, brain-tec/queue, bvkl/queue, camptocamp/queue, celm1990/queue, cocox/queue, cogitoweb/queue, consultingerp/odoo-addons-2, contineolabs/queue, coopdevs/odoo-addons, coopiteasy/queue, csveda/queue, dave-prosee/queue-from-magnus, dev00007/queue, diggy128/queue, dndoanh/queue, dong-z/queue, druidoo-dev/queue, dynapps/queue, ecosoft-odoo/queue, ecosoft-odoo/rjc, eezee-it/queue, egbonrelu/queue, ehsu0407/queue, em230418/queue, emiproenterprise/queue, eneldoserrata/queue, eslammohamed13/odoo-addons, etobella/queue, exosoftware/oca-queue, factorlibre/queue, fengzoo2018/queue, florian-dacosta/queue, fr33co/queue, glovebx/queue, guewen/connector, guewen/queue, guwenfeng/queue, haroldtamo/queue, hibou-io/oca-queue, hinfo506/queue, hpatelserpentcs/queue, hq8399/queue, hustlercoder/queue, hzwzw/queue, igor-mitin/queue, ilyasbahridudak/queue, isoscl/queue, jsilvestar/queue, kevin070982/odoo-project-10.0, kingofsevens/queue, kit9/odoo-addons-1, leanhtuan1996/queue, lepistone/queue, libregob/queue, lideritjnma/queue, limingsichuan/queue, lincersolucoes/oca-queue, liweijie0812/queue, loftwah/queue, lonelyleaves/queue, lonelysun/queue, magnuscolors/queue, marcelsavegnago/odoo-addons, marcelsavegnago/queue, mauraco-group/queue, maykonAguiar/queue, mozaik-association/queue, nadiaafa/queue, nilshamerlinck/queue, nodoo/queue, omalbastin/queue, one2pret/queue, ontruck/queue, phatdo-novobi/queue, popcomputadores-desenv/queue, praxigento/oca-queue, profumang/queue, pscloud/queue, qtheuret/queue, raizs/queue, rlfss/queue, rodrig92/odoo-addons-1, royalline1/queue, sahil-navadiya/queue, samuel-fringeli/queue, sanube/queue, sc4you/queue, sewisoft/queue, shengyf1/queue, shepilov-vladislav/queue, simahawk/queue, sotsam/queue, steingabelgaard/queue, stephen144/queue, subteno-it/queue, sunflowerit/queue, sunshineLhj/queue, tajawal/queue, takinobori/oca-queue, tandrieuxx/queue, tarteo/queue, tegin/queue, telesoho/queue, thanhchatvn/queue, thanhchatvn/saas-addons, themreza/queue, thinkopensolutions/oca-queue, thoongnv/queue, tirma-sa/queue, traviswaelbro/queue, tuannguyen-itit/queue, unitek-solusi/OCA-queue, ursais/queue, versada/queue, vijay-erpharbor/queue, vinaybhawsar/queue, vjd8866/queue, vnsofthe/queue, vrenaville/queue, wahello/acysos-odoo-addons, westlyou/queue-1, wjshan/queue, wty0512/queue, x0rzkov/odoo-queue, xcgd/queue, xwh123807/queue, yangshii/queue, yucer/queue, zakiuu/queue, and zhaowenzhe/queue

<a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.svg"> </a> <a name="job-queue"></a> <h2>Job Queue</h2> <p>This addon adds an integrated Job Queue to Odoo.</p> <p>It allows to postpone method calls executed asynchronously.</p> <p>Jobs are executed in the background by a <code>Jobrunner</code>, in their own transaction.</p> <p>Example:</p> <pre> <code lang="python">class MyModel(models.Model): _name = 'my.model' &#64;api.multi &#64;job def my_method(self, a, k=None): _logger.info('executed with a: %s and k: %s', a, k) class MyOtherModel(models.Model): _name = 'my.other.model' &#64;api.multi def button_do_stuff(self): self.env['my.model'].with_delay().my_method('a', k=2)</code> </pre> <p>In the snippet of code above, when we call <code>button_do_stuff</code>, a job capturing the method and arguments will be postponed. It will be executed as soon as the Jobrunner has a free bucket, which can be instantaneous if no other job is running.</p> <p>Features: * Views for jobs, jobs are stored in PostgreSQL * Jobrunner: execute the jobs, highly efficient thanks to PostgreSQL's NOTIFY * Channels: give a capacity for the root channel and its sub-channels and</p> <blockquote> segregate jobs in them. Allow for instance to restrict heavy jobs to be executed one at a time while little ones are executed 4 at a times.</blockquote> <ul class="simple"> <li>Retries: Ability to retry jobs by raising a type of exception</li> <li>Retry Pattern: the 3 first tries, retry after 10 seconds, the 5 next tries, retry after 1 minutes, ...</li> <li>Job properties: priorities, estimated time of arrival (ETA), custom description, number of retries</li> <li>Related Actions: link an action on the job view, such as open the record concerned by the job</li> </ul> <a name="installation"></a> <h3>Installation</h3> <p>Be sure to have the <code>requests</code> library.</p> <a name="configuration"></a> <h3>Configuration</h3> <ul class="simple"> <li>Using environment variables and command line:</li> </ul> <blockquote> <ul class="simple"> <li>Adjust environment variables (optional):</li> </ul> <blockquote> <ul class="simple"> <li><code>ODOO_QUEUE_JOB_CHANNELS=root:4</code></li> </ul> <blockquote> <ul class="simple"> <li>or any other channels configuration. The default is <code>root:1</code></li> </ul> </blockquote> <ul class="simple"> <li>if <code>xmlrpc_port</code> is not set: <code>ODOO_QUEUE_JOB_PORT=8069</code></li> </ul> </blockquote> <ul class="simple"> <li>Start Odoo with <code>--load=web,web_kanban,queue_job</code> and <code>--workers</code> greater than 1. <a class="footnote-reference" href="#id2" id="id1">[1]</a></li> </ul> </blockquote> <ul class="simple"> <li>Using the Odoo configuration file:</li> </ul> <pre> <code lang="ini">[options] (...) workers = 4 server_wide_modules = web,web_kanban,queue_job (...) [queue_job] channels = root:4</code> </pre> <ul class="simple"> <li>Confirm the runner is starting correctly by checking the odoo log file:</li> </ul> <pre> <code lang="none">...INFO...queue_job.jobrunner.runner: starting ...INFO...queue_job.jobrunner.runner: initializing database connections ...INFO...queue_job.jobrunner.runner: queue job runner ready for db &lt;dbname&gt; ...INFO...queue_job.jobrunner.runner: database connections ready</code> </pre> <ul class="simple"> <li>Create jobs (eg using <code>base_import_async</code>) and observe they start immediately and in parallel.</li> <li>Tip: to enable debug logging for the queue job, use <code>--log-handler=odoo.addons.queue_job:DEBUG</code></li> </ul> <table class="docutils footnote" frame="void" id="id2" rules="none"> <colgroup><col class="label" /><col /></colgroup> <tbody valign="top"> <tr><td class="label"><a class="fn-backref" href="#id1">[1]</a></td><td>It works with the threaded Odoo server too, although this way of running Odoo is obviously not for production purposes.</td></tr> </tbody> </table> <a name="usage"></a> <h3>Usage</h3> <p>To use this module, you need to:</p> <ol class="arabic simple"> <li>Go to <code>Job Queue</code> menu</li> </ol> <a class="reference external image-reference" href="https://runbot.odoo-community.org/runbot/230/10.0"><img alt="Try me on Runbot" src="https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas" /></a> <a name="known-issues-roadmap"></a> <h3>Known issues / Roadmap</h3> <ul class="simple"> <li>After creating a new database or installing <code>queue_job</code> on an existing database, Odoo must be restarted for the runner to detect it.</li> <li>When Odoo shuts down normally, it waits for running jobs to finish. However, when the Odoo server crashes or is otherwise force-stopped, running jobs are interrupted while the runner has no chance to know they have been aborted. In such situations, jobs may remain in <code>started</code> or <code>enqueued</code> state after the Odoo server is halted. Since the runner has no way to know if they are actually running or not, and does not know for sure if it is safe to restart the jobs, it does not attempt to restart them automatically. Such stale jobs therefore fill the running queue and prevent other jobs to start. You must therefore requeue them manually, either from the Jobs view, or by running the following SQL statement <em>before starting Odoo</em>:</li> </ul> <pre> <code lang="sql">update queue_job set state='pending' where state in ('started', 'enqueued')</code> </pre> <a name="bug-tracker"></a> <h3>Bug Tracker</h3> <p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/queue/issues">GitHub Issues</a>. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed feedback.</p> <a name="credits"></a> <h3>Credits</h3> <a name="images"></a> <h4>Images</h4> <ul class="simple"> <li>Odoo Community Association: <a class="reference external" href="https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg">Icon</a>.</li> </ul> <a name="contributors"></a> <h4>Contributors</h4> <ul class="simple"> <li>Guewen Baconnier &lt;<a class="reference external" href="mailto:guewen.baconnier&#64;camptocamp.com">guewen.baconnier&#64;camptocamp.com</a>&gt;</li> <li>Stéphane Bidoul &lt;<a class="reference external" href="mailto:stephane.bidoul&#64;acsone.eu">stephane.bidoul&#64;acsone.eu</a>&gt;</li> <li>Matthieu Dietrich &lt;<a class="reference external" href="mailto:matthieu.dietrich&#64;camptocamp.com">matthieu.dietrich&#64;camptocamp.com</a>&gt;</li> <li>Jos De Graeve &lt;<a class="reference external" href="mailto:Jos.DeGraeve&#64;apertoso.be">Jos.DeGraeve&#64;apertoso.be</a>&gt;</li> <li>David Lefever &lt;<a class="reference external" href="mailto:dl&#64;taktik.be">dl&#64;taktik.be</a>&gt;</li> <li>Laurent Mignon &lt;<a class="reference external" href="mailto:laurent.mignon&#64;acsone.eu">laurent.mignon&#64;acsone.eu</a>&gt;</li> <li>Laetitia Gangloff &lt;<a class="reference external" href="mailto:laetitia.gangloff&#64;acsone.eu">laetitia.gangloff&#64;acsone.eu</a>&gt;</li> </ul> <a name="maintainer"></a> <h4>Maintainer</h4> <a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a> <p>This module is maintained by the OCA.</p> <p>OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.</p> <p>To contribute to this module, please visit <a class="reference external" href="https://odoo-community.org">https://odoo-community.org</a>.</p>