Hermann Himmelbauer wrote:
> Hi,
> I'm experiencing some interesting error here with SQLAlchemy:
> When I execute one of my functions, which do a simple session.query, the 
> following traceback occurs, but only sometimes - no clue why and when:
>
> ----------------------- snip -----------------------
>   File "/home/bank/zbsp/buildout/src/bsp/bsp/torder.py", line 183, in 
> search_torder_tmpl
>     customer = get_customer(bspconf, session, customerid=customerid)
>   File "/home/bank/zbsp/buildout/src/bsp/bsp/customer.py", line 71, in 
> get_custo
> mer
>     customer = session.query(Customer).filter_by( 
> File 
> "/home/bank/zbsp/buildout/eggs/SQLAlchemy-0.5.4p1-py2.4.egg/sqlalchemy/orm/query.py",
>  
> line 1226, in first
>     ret = list(self[0:1]) 
> File 
> "/home/bank/zbsp/buildout/eggs/SQLAlchemy-0.5.4p1-py2.4.egg/sqlalchemy/orm/query.py",
>  
> line 1147, in __getitem__
>     return list(res) 
> File 
> "/home/bank/zbsp/buildout/eggs/SQLAlchemy-0.5.4p1-py2.4.egg/sqlalchemy/orm/query.py",
>  
> line 1286, in __iter__
>     self.session._autoflush() 
> File 
> "/home/bank/zbsp/buildout/eggs/SQLAlchemy-0.5.4p1-py2.4.egg/sqlalchemy/orm/session.py",
>  
> line 899, in _autoflush
>     self.flush() 
> File 
> "/home/bank/zbsp/buildout/eggs/SQLAlchemy-0.5.4p1-py2.4.egg/sqlalchemy/orm/session.py",
>  
> line 1354, in flush
>     self._flush(objects) 
> File 
> "/home/bank/zbsp/buildout/eggs/SQLAlchemy-0.5.4p1-py2.4.egg/sqlalchemy/orm/session.py",
>  
> line 1359, in _flush
>     if (not self.identity_map.check_modified() and 
> File 
> "/home/bank/zbsp/buildout/eggs/SQLAlchemy-0.5.4p1-py2.4.egg/sqlalchemy/orm/identity.py",
>  
> line 56, in check_modified
>     for state in self._mutable_attrs:
> RuntimeError: dictionary changed size during iteration
> ----------------- snip ------------------
>
> Any hints about what to do?
>   

Looks like this was a bug and was fixed in 0.5.6. Time to upgrade?

You may be able to work around this issue somewhat by forcing a garbage
collection just before your query:
import gc
...
gc.collect()
customer = session.query(Customer).filter_by(
...

-Conor

--

You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.


Reply via email to