On 4/2/15 4:28 PM, Evan James wrote: > Hi folks, > > While running my test suite, I hit an issue with the following stack > trace: > > | > ERROR at setup of test_track_before_delete > > > request > =<SubRequest'database_session'for<Function'test_track_before_delete'>>,engine > =Engine(sqlite:///test.db) > > > > > @pytest.fixture > > defdatabase_session(request,engine): > > connection =engine.connect() > > trans =connection.begin() > > > > > meta.Session=scoped_session(sessionmaker(autocommit=False,autoflush=True,bind=connection)) > > register_session_listeners(meta.Session) > > > > meta.Session.begin_nested() > > > @event.listens_for(meta.Session,"after_transaction_end") > > defrestart_savepoint(session,transaction): > > iftransaction.nested andnottransaction._parent.nested: > > > > > automated_tests/conftest.py:52: > > _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > > ../../../.virtualenvs/ERP/lib/python2.7/site-packages/sqlalchemy/event/api.py:94:indecorate > > > listen(target,identifier,fn,*args,**kw) > > ../../../.virtualenvs/ERP/lib/python2.7/site-packages/sqlalchemy/event/api.py:63:inlisten > > > _event_key(target,identifier,fn).listen(*args,**kw) > > ../../../.virtualenvs/ERP/lib/python2.7/site-packages/sqlalchemy/event/registry.py:187:inlisten > > > self.dispatch_target.dispatch._listen(self,*args,**kw) > > ../../../.virtualenvs/ERP/lib/python2.7/site-packages/sqlalchemy/event/base.py:184:in_listen > > > event_key.base_listen(propagate=propagate,insert=insert,named=named) > > ../../../.virtualenvs/ERP/lib/python2.7/site-packages/sqlalchemy/event/registry.py:226:inbase_listen > > > for_modify(target.dispatch).append(self,propagate) > > ../../../.virtualenvs/ERP/lib/python2.7/site-packages/sqlalchemy/event/attr.py:118:inappend > > > registry._stored_in_collection(event_key,self) > > _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > > > > event_key =<sqlalchemy.event.registry._EventKey objectat > 0x111c6b3d0>,owner =<sqlalchemy.event.attr._DispatchDescriptor > objectat 0x10eac8590> > > > > > def_stored_in_collection(event_key,owner): > > key =event_key._key > > > > dispatch_reg =_key_to_collection[key] > > > > owner_ref =owner.ref > > listen_ref =weakref.ref(event_key._listen_fn) > > > > ifowner_ref indispatch_reg: > > > assertdispatch_reg[owner_ref]==listen_ref > > E assert<weakref at 0x111cc25d0;dead>==<weakref at > 0x111cc2af8;to 'function'at 0x111c7f668(restart_savepoint)> > > > > > ../../../.virtualenvs/ERP/lib/python2.7/site-packages/sqlalchemy/event/registry.py:74:AssertionError > | > > > While running the @event.listens_for decorator in the setup of a test > fixture, SQLAlchemy throws an assertion because the ref it has in the > dispatch registry isn't identical to the ref to the listener function. > We're on SQLAlchemy 0.9.7, pytest 2.6.4. Note that the test suite is > setting up nested transactions on SQLite; we are using the recommended > workaround from SQLAlchemy documentation to take control of > transactional integration from pysqlite. > > > Since there's an assertion in the code in _stored_in_collection(), I > assume that there's some expectation that the refs might not match; am > I doing something wrong in my setup which this assertion is meant to > catch? I've only seen this error once (while tracking down a > different nondeterministic error in my own app's code), so I can't > provide much more information than this, but the portion of test > fixture code seen above in the stack trace is basically the entire > reproduction case. This fixture runs before every test in my suite, > but I've only seen an error once across a large number of runs, so the > error is *very* intermittent. Because of that, I'm not worried too > much about the error itself, but I thought I should post it here in > case it's a symptom of something I should be worrying about. > this was issue https://bitbucket.org/zzzeek/sqlalchemy/issue/3199 and has been fixed as of 0.9.8.
> > Thanks, > > Evan James > > -- > You received this message because you are subscribed to the Google > Groups "sqlalchemy" group. > To unsubscribe from this group and stop receiving emails from it, send > an email to sqlalchemy+unsubscr...@googlegroups.com > <mailto:sqlalchemy+unsubscr...@googlegroups.com>. > To post to this group, send email to sqlalchemy@googlegroups.com > <mailto:sqlalchemy@googlegroups.com>. > Visit this group at http://groups.google.com/group/sqlalchemy. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.