def rollback(self, tx): self._assert_open() self._assert_transaction_open(tx) self._transaction.set_complete() log.debug("[#%04X] C: RUN 'ROLLBACK' {}", self.local_port) log.debug("[#%04X] C: DISCARD_ALL", self.local_port) try: self._sync(self._write_request(0x10, "ROLLBACK", {}), self._write_request(0x2F)) except BrokenWireError as error: tx.mark_broken() raise_from( BrokenTransactionError("Transaction broken by disconnection " "during rollback"), error) else: try: self._audit(self._transaction) except Failure as failure: tx.mark_broken() raise_from( BrokenTransactionError("Failed to rollback transaction"), failure) else: return Bookmark() finally: if callable(self._on_unbind): self._on_unbind(self._transaction)
def rollback(self, tx): self._assert_open() self._assert_transaction_open(tx) self._transaction.set_complete() log.debug("[#%04X] C: ROLLBACK", self.local_port) response = self._write_request(0x13) try: self._sync(response) except BrokenWireError as error: tx.mark_broken() raise_from( BrokenTransactionError("Transaction broken by disconnection " "during rollback"), error) else: try: self._audit(self._transaction) except Failure as failure: tx.mark_broken() raise_from( BrokenTransactionError("Failed to rollback transaction"), failure) else: return Bookmark(response.metadata.get("bookmark")) finally: if callable(self._on_unbind): self._on_unbind(self._transaction)
def rollback(self, tx): self._assert_transaction_open(tx) self.__transactions.remove(tx) try: r = self._delete(tx.uri()) except ConnectionError as error: tx.mark_broken() raise_from( BrokenTransactionError("Transaction broken by disconnection " "during rollback"), error) except HTTPError as error: tx.mark_broken() raise_from( BrokenTransactionError("Transaction broken by HTTP error " "during rollback"), error) else: if r.status != 200: tx.mark_broken() raise BrokenTransactionError( "Transaction broken by HTTP %d status " "during rollback" % r.status) rs = HTTPResponse.from_json(r.status, r.data.decode("utf-8")) self.release() rs.audit(tx) return Bookmark()
def header(self): try: self.__cx.sync(self) except BrokenWireError as error: raise_from( BrokenTransactionError("Transaction broken by disconnection " "while buffering query result"), error) return self._items[0]
def buffer(self): if self.done(): return try: self.__cx.sync(self) except BrokenWireError as error: self.__cx.transaction.mark_broken() raise_from(BrokenTransactionError("Transaction broken by disconnection " "while buffering"), error)
def buffer(self): if not self.done(): try: self.__cx.sync(self) except BrokenWireError as error: raise_from( BrokenTransactionError( "Transaction broken by disconnection " "while buffering query result"), error)
def run_in_tx(self, tx, cypher, parameters=None): r = self._post(tx.uri(), cypher, parameters) if r.status != 200: tx.mark_broken() raise BrokenTransactionError("Transaction broken by HTTP %d status " "during query execution" % r.status) rs = HTTPResponse.from_json(r.status, r.data.decode("utf-8")) self.release() rs.audit(tx) return HTTPResult(tx.graph_name, rs.result(), profile=self.profile)
def commit(self, tx): if tx.broken: raise ValueError("Transaction is broken") try: r = self._post(tx.commit_uri()) except ConnectionError as error: tx.mark_broken() raise_from(BrokenTransactionError("Transaction broken by disconnection " "during commit"), error) except HTTPError as error: tx.mark_broken() raise_from(BrokenTransactionError("Transaction broken by HTTP error " "during commit"), error) else: if r.status != 200: tx.mark_broken() raise BrokenTransactionError("Transaction broken by HTTP %d status " "during commit" % r.status) rs = HTTPResponse.from_json(r.status, r.data.decode("utf-8")) self.release() rs.audit(tx) return Bookmark()
def commit(self, tx): self._assert_open() self._assert_transaction_open(tx) self._transaction.set_complete() log.debug("[#%04X] C: RUN 'COMMIT' {}", self.local_port) log.debug("[#%04X] C: DISCARD_ALL", self.local_port) try: self._sync(self._write_request(0x10, "COMMIT", {}), self._write_request(0x2F)) except BrokenWireError as error: raise_from( BrokenTransactionError("Transaction broken by disconnection " "during commit"), error) else: self._audit(self._transaction) if callable(self._on_unbind): self._on_unbind(self._transaction) return Bookmark()