def begin(self):
if hasattr(self._locals, '<STR_LIT>') and self._locals.transaction_exists:<EOL><INDENT>raise TransactionError("<STR_LIT>")<EOL><DEDENT>if self.state != _STATE_NOT_STARTED:<EOL><INDENT>raise TransactionError("<STR_LIT>")<EOL><DEDENT>self._locals.transaction_exists = True<EOL>self.start_time = time.time()<EOL>self.thread_id = thread_id()<EOL>try:<EOL><INDENT>request = transaction_create_codec.encode_request(timeout=int(self.timeout * <NUM_LIT:1000>), durability=self.durability,<EOL>transaction_type=self.transaction_type,<EOL>thread_id=self.thread_id)<EOL>response = self.client.invoker.invoke_on_connection(request, self.connection).result()<EOL>self.id = transaction_create_codec.decode_response(response)["<STR_LIT>"]<EOL>self.state = _STATE_ACTIVE<EOL><DEDENT>except:<EOL><INDENT>self._locals.transaction_exists = False<EOL>raise<EOL><DEDENT>
Begins this transaction.