Hi,

I've run into troubles with a TurboGears2-application that showed a difficult 
to 
track error when being integration tested - but not when the same test was run 
locally.

Eventually I could track things down to two tests run after another - the first 
somehow setting up the SA session in a way that the second test wouldn't 
perform pending inserts - resulting in the observed errorneus behavior.

Eventually I was able to solve the problem by putting a session.close() into 
our transactional decorator, which roughly looks like this:


def transactional(f):
    @wraps(f)
    def _d(*args, **kwargs):
          session = DBSession()
          rollback = False
          try:
              session.begin()
              return f(*args, **kwargs)
         except:
             rollback = True
             raise
         finally:
            if rollback:
               session.rollback()
            else:
               session.commit()
           session.close() # <--------- this was the fix


Now I wonder - in a non-nested transactional scenario, what does close what 
commit/rollback don't do? Especially rollback, as the first of the two tests 
was essentially triggering a rollback.


Diez
 

--~--~---------~--~----~------------~-------~--~----~
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