original_docstring:  open the connection to the database
  
          :param soft: Attempt to re-use the connection, if False (default), create a new socket
          :type soft: bool
          
docstring: open the connection to the database
docstring_tokens: open the connection to the database
code: def open(self, soft=False):
          """ open the connection to the database
  
          :param soft: Attempt to re-use the connection, if False (default), create a new socket
          :type soft: bool
          """
          for i in range(CONNECTION_ATTEMPTS):
              if not soft:
                  # connect to server
                  self._conn = self.SOCKET_CLASS()
                  self._conn.settimeout(self.timeout)
  
  
                  if isinstance(self.host, list):
                      host_choices = set(self.host) - self.host_blacklist
                      self.current_host = random.choice(list(host_choices))
                  else:
                      self.current_host = self.host
  
                  if isinstance(self.port, list):
                      port_choices = set(self.port) - self.port_blacklist
                      self.current_port = random.choice(list(port_choices))
                  else:
                      self.current_port = self.port
  
                  try:
                      self._conn.connect((self.current_host, self.current_port))
  
                  except Exception as e:
                      self.connection_failed()
  
                      logger.error(u"Titan query failed on host {} and port {}: {}. Current client is host={} post={}".format(
                          self.current_host, self.current_port, e, self.host_blacklist, self.port_blacklist))
  
                      continue
  
              try:
                  # indicates that we're in a transaction
                  self._in_transaction = False
  
                  # stores the session key
                  self._session_key = None
                  self._opened = True
                  self._open_session()
                  return
  
              except Exception, e:
                  soft = False
                  self.connection_failed()
                  logger.exception("Could not connect to database: %s" % e)
                  if i >= CONNECTION_ATTEMPTS - 1:
                      raise
code_tokens: def open ( self , soft = False ) : for i in range ( CONNECTION_ATTEMPTS ) : if not soft : self . _conn = self . SOCKET_CLASS ( ) self . _conn . settimeout ( self . timeout ) if isinstance ( self . host , list ) : host_choices = set ( self . host ) - self . host_blacklist self . current_host = random . choice ( list ( host_choices ) ) else : self . current_host = self . host if isinstance ( self . port , list ) : port_choices = set ( self . port ) - self . port_blacklist self . current_port = random . choice ( list ( port_choices ) ) else : self . current_port = self . port try : self . _conn . connect ( ( self . current_host , self . current_port ) ) except Exception as e : self . connection_failed ( ) logger . error ( u"Titan query failed on host {} and port {}: {}. Current client is host={} post={}" . format ( self . current_host , self . current_port , e , self . host_blacklist , self . port_blacklist ) ) continue try : self . _in_transaction = False self . _session_key = None self . _opened = True self . _open_session ( ) return except Exception , e : soft = False self . connection_failed ( ) logger . exception ( "Could not connect to database: %s" % e ) if i >= CONNECTION_ATTEMPTS - 1 : raise
short_docstring: open the connection to the database
short_docstring_tokens: open the connection to the database
comment: """ open the connection to the database
  
          :param soft: Attempt to re-use the connection, if False (default), create a new socket
          :type soft: bool
          """$SEP$# connect to server$SEP$# indicates that we're in a transaction$SEP$# stores the session key