-
Notifications
You must be signed in to change notification settings - Fork 59
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
Bug: dictionary changed size during iteration #507
Comments
Without a minimal reproducible example, we can't ensure that PR #508 effectively fixed the issue. |
For now you have to believe me that this fixed my project :) For the foreseeable future I will update the PR but not in upcoming week. |
I think you should provide an example use case. |
I'm unable to find the root cause and thus cannot provide a failing test case. |
I have the same error with class PreparationPhaseDB(MappedAsDataclass, BaseDB):
__tablename__ = "preparation_phases"
attachments: AssociationProxy[list[AttachmentDB]] = association_proxy( # problem attr
"attachments_relationship", "attachment", init=False
)
attachments_relationship: Mapped[list[PreparationPhaseAttachmentRelationDB]] = (
relationship(lazy="noload", init=False)
)
admin = Admin(engine=engine, ...)
admin.add_view(ModelView(PreparationPhaseDB, name="phases"))
|
I change loop code for key in self.model.__dict__.keys: to for key in list(self.model.__dict__.keys()): and now it just works |
Great, thanks for sharing the fix. feel free to submit PR with your example as a test case |
Somehow my models aren't completely loaded when the admin is initialized. During the setup of the admin fields are added to the model and therefore
self.model.__dict__
changed size during iteration.Fixing the problem is easier than isolating a test case, so I do not have something to reproduce the error.
The text was updated successfully, but these errors were encountered: