Garbage collection causes spurious Set changed size during iteration errors.
Issue #1493
resolved
The following abbreviated stack trace shows a spurious error happening with SQLAlchemy. Tested with SQLAlchemy 0.5.3 and Python 2.5 and SQLAlchemy 0.5.5 with Python 2.6.
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/SQLAlchemy-0.5.5-py2.6.egg/sqlalchemy/orm/dynamic.py", line 192, in __iter__
sess = self.__session()
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/SQLAlchemy-0.5.5-py2.6.egg/sqlalchemy/orm/dynamic.py", line 181, in __session
sess.flush()
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/SQLAlchemy-0.5.5-py2.6.egg/sqlalchemy/orm/session.py", line 1354, in flush
self._flush(objects)
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/SQLAlchemy-0.5.5-py2.6.egg/sqlalchemy/orm/session.py", line 1359, in _flush
if (not self.identity_map.check_modified() and
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/SQLAlchemy-0.5.5-py2.6.egg/sqlalchemy/orm/identity.py", line 56, in check_modified
for state in self._mutable_attrs:
RuntimeError: Set changed size during iteration
The work around is to turn off garbage collection with gc.disable().
To take a guess at what's wrong, self._mutable_attrs probably contains weak reference elements that may disappear during garbage collection which breaks the iteration.
I posted some additional information here:
Comments (2)
-
repo owner -
repo owner - removed milestone
Removing milestone: 0.5.6 (automated comment)
- Log in to comment
I replied on the blog post. the issue is fixed in the current trunk (0.5.6).