title: How to use nested transaction with scoped session in SQLAlchemy?
body: <p>I have written code bellow for handling nested transaction throughout my application. But when it rollback once after that all the transaction get rollback till I restart application.</p>
  
  <pre><code># method_a starts a transaction and calls method_b
  def method_a():
      session.begin(subtransactions=True)
      try:
          method_b()
          session.commit()  # transaction is committed here
      except:
          session.rollback() # rolls back the transaction
  
  
  # method_b also starts a transaction, but when
  # called from method_a participates in the ongoing
  # transaction.
  def method_b():
      session.begin(subtransactions=True)
      try:
          session.add(SomeObject('bat', 'lala'))
          session.commit()  # transaction is not committed yet
      except:
          session.rollback() # rolls back the transaction, in this case
                         # the one that was initiated in method_a().
  
  
  # create a Session and call method_a
  session = Session(autocommit=True)
  global session
  method_a(session)
  </code></pre>