Well after a day of tracking this down, I found that has something to do with reference cycles. Not sure what exactly, but making an attribute non-persistent solved the problem. And nothing to do with SQLAlchemy.
Has anyone else noticed that pickle is not the most robust of protocols? There seems to be differences between pypickle and cpickle, and various protocol versions. And the original error was only intermittent (even in a single thread, so not concurrency- related). As an aside, when using pypickle, protocol=2, I get this error with ordering_list: pickle:1182 load_append list.append(value) sqlalchemy.orm.collections:918 append fn(self, item) sqlalchemy.ext.orderinglist:234 append self._order_entity(len(self) - 1, entity, self.reorder_on_append) AttributeError: 'OrderingList' object has no attribute 'reorder_on_append' On Feb 14, 5:48 am, Michael Bayer <mike...@zzzcomputing.com> wrote: > On Feb 13, 2010, at 11:03 AM, avdd wrote: > > > > > I'm getting some strange errors with unpickling. I've tried all > > combinations of pickle/cPickle and protocol in (0,1,2) and still > > getting this apparent random error: > > > sqlalchemy.orm.collections:622 __setstate__ > > self.attr = getattr(d['owner_state'].obj().__class__, > > d['key']).impl > > AttributeError: type object 'NoneType' has no attribute 'flights' > > > When I inspect this frame, I see that: > > >>>> d['owner_state'].obj > > <bound method InstanceState.obj of <sqlalchemy.orm.state.InstanceState > > object at 0xa1b5acc>> > > > So it seems that __setstate__ is not being called for the > > InstanceState object. > > pickling of instances (using 0.5.8 or 0.6beta) is widely tested and used > successfully in great volume, so you'd have to provide more specifics. note > that pickle formats may not be entirely compatible coming from an older > version of 0.5 (like pre 0.5.5) and 0.6. > > > > > Any ideas? > > > -- > > You received this message because you are subscribed to the Google Groups > > "sqlalchemy" group. > > To post to this group, send email to sqlalch...@googlegroups.com. > > To unsubscribe from this group, send email to > > sqlalchemy+unsubscr...@googlegroups.com. > > For more options, visit this group > > athttp://groups.google.com/group/sqlalchemy?hl=en. -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.