Skip to content

Problem with iteration over queue in .indexing.IndexQueue.process #79

@jensens

Description

@jensens

I wrote an multilingual fallback index for Plone plone.app.multilingualindexes. In order to get all items up to date, I need to cross-index objects. On unindex_object I need to reindex the same index of all objects in the same translation group. When doing so, for some reason (I did not figured out why) the for loop is reset:

for op, obj, attributes, metadata in self.queue:

I have two items in the queue and the first item is processed twice (and then unindex fails).
I took the debugger and stepped through to verify this.

No idea how. I guess the iterator of self.queue was reset while unindex runs.

I then tried to work around the iterator reset - which results in this code:

    while self.queue:
        op, obj, attributes, metadata = self.queue.pop(0)

see https://github.com/plone/plone.app.multilingualindexes/blob/e89cc65db76108d7050ef73b6171987fd2ba0d41/src/plone/app/multilingualindexes/patches.py#L18-L19

And now all works fine.

I would really like to provide a pull request, but I first I want to understand what happens here. Also, I have no good idea how to write a test for this effect.

Is anyone here with more insights/ ideas?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions