original_docstring: Perform a unit of work in a transaction, retrying on abort.
  
          :type func: callable
          :param func: takes a required positional argument, the transaction,
                       and additional positional / keyword arguments as supplied
                       by the caller.
  
          :type args: tuple
          :param args: additional positional arguments to be passed to ``func``.
  
          :type kw: dict
          :param kw: (Optional) keyword arguments to be passed to ``func``.
                     If passed, "timeout_secs" will be removed and used to
                     override the default retry timeout which defines maximum timestamp
                     to continue retrying the transaction.
  
          :rtype: Any
          :returns: The return value of ``func``.
  
          :raises Exception:
              reraises any non-ABORT exceptions raised by ``func``.
          
docstring: Perform a unit of work in a transaction, retrying on abort.
docstring_tokens: Perform a unit of work in a transaction retrying on abort .
code: def run_in_transaction(self, func, *args, **kw):
          """Perform a unit of work in a transaction, retrying on abort.
  
          :type func: callable
          :param func: takes a required positional argument, the transaction,
                       and additional positional / keyword arguments as supplied
                       by the caller.
  
          :type args: tuple
          :param args: additional positional arguments to be passed to ``func``.
  
          :type kw: dict
          :param kw: (Optional) keyword arguments to be passed to ``func``.
                     If passed, "timeout_secs" will be removed and used to
                     override the default retry timeout which defines maximum timestamp
                     to continue retrying the transaction.
  
          :rtype: Any
          :returns: The return value of ``func``.
  
          :raises Exception:
              reraises any non-ABORT exceptions raised by ``func``.
          """
          # Sanity check: Is there a transaction already running?
          # If there is, then raise a red flag. Otherwise, mark that this one
          # is running.
          if getattr(self._local, "transaction_running", False):
              raise RuntimeError("Spanner does not support nested transactions.")
          self._local.transaction_running = True
  
          # Check out a session and run the function in a transaction; once
          # done, flip the sanity check bit back.
          try:
              with SessionCheckout(self._pool) as session:
                  return session.run_in_transaction(func, *args, **kw)
          finally:
              self._local.transaction_running = False
code_tokens: def run_in_transaction ( self , func , * args , ** kw ) : if getattr ( self . _local , "transaction_running" , False ) : raise RuntimeError ( "Spanner does not support nested transactions." ) self . _local . transaction_running = True try : with SessionCheckout ( self . _pool ) as session : return session . run_in_transaction ( func , * args , ** kw ) finally : self . _local . transaction_running = False
short_docstring: Perform a unit of work in a transaction, retrying on abort.
short_docstring_tokens: Perform a unit of work in a transaction retrying on abort .
comment: """Perform a unit of work in a transaction, retrying on abort.
  
          :type func: callable
          :param func: takes a required positional argument, the transaction,
                       and additional positional / keyword arguments as supplied
                       by the caller.
  
          :type args: tuple
          :param args: additional positional arguments to be passed to ``func``.
  
          :type kw: dict
          :param kw: (Optional) keyword arguments to be passed to ``func``.
                     If passed, "timeout_secs" will be removed and used to
                     override the default retry timeout which defines maximum timestamp
                     to continue retrying the transaction.
  
          :rtype: Any
          :returns: The return value of ``func``.
  
          :raises Exception:
              reraises any non-ABORT exceptions raised by ``func``.
          """$SEP$# Sanity check: Is there a transaction already running?$SEP$# If there is, then raise a red flag. Otherwise, mark that this one$SEP$# is running.$SEP$# Check out a session and run the function in a transaction; once$SEP$# done, flip the sanity check bit back.