server/repository.py
changeset 9623 2171da5b9234
parent 9622 637a12b0d3a2
child 9629 8114bed10e78
equal deleted inserted replaced
9622:637a12b0d3a2 9623:2171da5b9234
   821             self.exception('unexpected error')
   821             self.exception('unexpected error')
   822             raise
   822             raise
   823 
   823 
   824     def close(self, sessionid, txid=None, checkshuttingdown=True):
   824     def close(self, sessionid, txid=None, checkshuttingdown=True):
   825         """close the session with the given id"""
   825         """close the session with the given id"""
   826         session = self._get_session(sessionid, setcnxset=True, txid=txid,
   826         session = self._get_session(sessionid, txid=txid,
   827                                     checkshuttingdown=checkshuttingdown)
   827                                     checkshuttingdown=checkshuttingdown)
   828         # operation uncommited before close are rolled back before hook is called
   828         # operation uncommited before close are rolled back before hook is called
   829         session._cnx.rollback(free_cnxset=False)
   829         if session._cnx._session_handled:
       
   830             session._cnx.rollback(free_cnxset=False)
   830         with session.new_cnx() as cnx:
   831         with session.new_cnx() as cnx:
   831             self.hm.call_hooks('session_close', cnx)
   832             self.hm.call_hooks('session_close', cnx)
   832             # commit connection at this point in case write operation has been
   833             # commit connection at this point in case write operation has been
   833             # done during `session_close` hooks
   834             # done during `session_close` hooks
   834             cnx.commit()
   835             cnx.commit()