Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[14.0][IMP] product_import: Import products asynchronously #1076

Open
wants to merge 2 commits into
base: 14.0
Choose a base branch
from

Conversation

florentx
Copy link
Contributor

@florentx florentx commented Nov 29, 2024

Some catalogs contain 10'000 references and import does not complete due to other tasks running at the same time, and locking table.

Splitting product import into individual jobs should mitigate this issue.

@florentx florentx force-pushed the product_import_job branch 6 times, most recently from 96ad6db to 4f485a1 Compare November 29, 2024 11:07
product_import/wizard/product_import.py Outdated Show resolved Hide resolved
product_import/tests/test_product_import.py Outdated Show resolved Hide resolved
product_import/wizard/product_import.py Outdated Show resolved Hide resolved
@florentx florentx requested a review from simahawk December 3, 2024 16:53
@florentx florentx force-pushed the product_import_job branch 2 times, most recently from 9bed83c to 967c912 Compare December 4, 2024 09:11
Copy link

@twalter-c2c twalter-c2c left a comment

Choose a reason for hiding this comment

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

LGTM

@florentx florentx force-pushed the product_import_job branch 2 times, most recently from a6f4537 to c246786 Compare December 9, 2024 08:06
@@ -13,9 +13,12 @@
"stock",
# OCA/edi
"base_business_document_import",
# OCA/queue
"queue_job",
Copy link
Contributor

Choose a reason for hiding this comment

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

I've thought again about this... We should remove this dependency IMO.
In the simplest case we won't need it, in the more complex case we'll probably use the framework. Then, we can leverage the framework to the split.
Additionally, there's now a new feature in queue_job which is called split and allows to.... split items in batches.
See OCA/queue#658

if products[-1] is None:
products = [product for product in products if product]
# One job for x products (chunk of 40)
wiz.with_delay()._create_update_products(products, seller.id)
Copy link
Contributor

Choose a reason for hiding this comment

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

here I would simply call wiz.create_update_products that will call _create_update_products which can be overridden or you can rely on https://github.com/OCA/queue/blob/16.0/queue_job/models/base.py#L145

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants