Skip to content

Commit

Permalink
[FIX] fixes a possible infinite loop when computing variants
Browse files Browse the repository at this point in the history
  • Loading branch information
nayatec committed Nov 21, 2024
1 parent bf56db4 commit 992044f
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions shopinvader_search_engine/models/shopinvader_variant.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# @author Sébastien BEAU <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from sys import exc_info

from odoo import models


Expand Down Expand Up @@ -29,6 +31,21 @@ def _get_binding_to_process(self, bindings, batch_size):
== bindings[idx].shopinvader_product_id
):
idx += 1
return processing | bindings[0:idx], bindings[idx:]
else:
return processing, bindings
processing, bindings = processing | bindings[0:idx], bindings[idx:]
if not bindings:
# if there is no bindings that means that the job has not
# been splitted. If we are in an exception we just re raise it
# and the whole list of variants will not be computed.
# Not doing so would result in an infinite loop unless we
# force splitting to go down to the exact variant that raises
# the error, but at the expense of possibly a lot of jobs created
# raising errors.
# Note that it can lead to variants not being recomputed which
# should have been recomputed without error.

# Note : from python 3.11 on use sys.exception() instead
e = exc_info()[1]
if e:
raise e

return processing, bindings

0 comments on commit 992044f

Please sign in to comment.