Skip to content

Conversation

@romi477
Copy link
Contributor

@romi477 romi477 commented Oct 25, 2021

No description provided.

Guewen Baconnier and others added 30 commits October 21, 2021 14:03
To avoid to pollute 'queue.job.function' with a test job.
The model name, method name, recordset ids, arguments and keyword
arguments must never ever be modified after the creation of a job.
This change fix a bug when a job with a mutable argument see the content
of the argument being modified during the execution of a job.
In addition to the ODOO_CONNECTOR_CHANNELS environment variable, for
backward compatibility, we can configure the runner channels through
the ODOO_QUEUE_JOB_CHANNELS and in the odoo configuration file like this:

    [options-job_queue]
    channels = root:4

For backward compatibility, the section `[options-connector]` is also
accepted.

Moreover, it's now also possible to preload the module in the config
file, like:

    [options]
    server_wide_modules = web,web_kanban,queue_job

As such we can configure the job runner using only the Odoo config file.
Ignore whitespace around values, and tolerate missing entries that would
be caused by trailing commas or commented lines when the channel
configuration is provided through the Odoo configuration file.

Also, accept line breaks channel entry separators along with commas,
which make the configuration file more readable.
Or replace them with references to queue_job.

Also, rip off the barely useful modicum of backward compatibility.
Useful for debugging if jobs when we want to know if and when a job is
being enqueued. It will log something like:

odoo.addons.queue_job.job: enqueued model.name(1, 2, 3, ):method_name(*(arg1, arg2, ...), **{'kwarg1': 'value1', 'kwarg2': 'value2', ...}) with uuid: fdec21f5-7579-49b3-a80c-1ba91a6f3cfa
Instead of trying to parse error messages from postgres, check the
existence of the module table with a non-exception-raising query.

The `unicode(err)` cast failed with postgres in locales that generated
error messages with non-ascii chars.
Add JSON encoder and decoder for datetime and date values in the jobs so
we can use these types in job arguments.
When a job is enqueued with recordsets in args/kwargs, they are
serialized as json. When they are deserialized, until now the recorsets
were read using the admin user.  With this change, the original user is
included in the json, so we can read the recordset with the original user.
oca-transbot and others added 12 commits October 21, 2021 14:03
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: queue-14.0/queue-14.0-queue_job
Translate-URL: https://translation.odoo-community.org/projects/queue-14-0/queue-14-0-queue_job/
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: queue-14.0/queue-14.0-queue_job
Translate-URL: https://translation.odoo-community.org/projects/queue-14-0/queue-14-0-queue_job/
This patch method has to be called in ``_register_hook``.

When a method is patched, any call to the method will not directly
execute the method's body, but will instead enqueue a job.

When a ``context_key`` is set when calling ``_patch_job_auto_delay``,
the patched method is automatically delayed only when this key is
``True`` in the caller's context. It is advised to patch the method
with a ``context_key``, because making the automatic delay *in any
case* can produce nasty and unexpected side effects (e.g. another
module calls the method and expects it to be computed before doing
something else, expecting a result, ...).

A typical use case is when a method in a module we don't control is called
synchronously in the middle of another method, and we'd like all the calls
to this method become asynchronous.

It relies on OCA#274 that deprecates the
`@job` decorator.
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: queue-14.0/queue-14.0-queue_job
Translate-URL: https://translation.odoo-community.org/projects/queue-14-0/queue-14-0-queue_job/
@romi477 romi477 force-pushed the 15.0-mig-queue_job branch from a322778 to d37c8cf Compare October 26, 2021 09:33
@ventor-dev
Copy link

@pedrobaeza looks like workflow is not running, because @romi477 is first time contributor. Could you, please, check and approve workflows?

@romi477 romi477 force-pushed the 15.0-mig-queue_job branch from d37c8cf to 81579a7 Compare November 1, 2021 10:15
@ventor-dev
Copy link

@guewen could you, please, review and approve

Copy link
Member

@guewen guewen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the work!

@OCA-git-bot
Copy link
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

@ventor-dev
Copy link

@guewen I guess you need to merge it now?

@guewen
Copy link
Member

guewen commented Nov 1, 2021

@ventor-dev usually in this repository, we keep the branch and set modules as uninstallable, I didn't had the opportunity to prepare the branch this way. I'm about to force-push the branch to restore the history, then, I cherry-picked your commits in a new branch. I'll open a PR with this branch to check the CI.

@guewen
Copy link
Member

guewen commented Nov 1, 2021

BTW, I didn't see before, you missed the module test_queue_job which is necessary to ensure everything is working correctly

@pedrobaeza
Copy link
Member

Note that this flow is an exception made by the maintainers of this repository, not the usual OCA flow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.