#NEWLINE# def set_connections( self , hosts ) : #NEWLINE# #INDENT# '\n        Instantiate all the connections and crate new connection pool to hold\n        them. Tries to identify unchanged hosts and re-use existing\n        :class:`~elasticsearch.Connection` instances.\n\n        :arg hosts: same as `__init__`\n        ' #NEWLINE# def _create_connection( host ) : #NEWLINE# #INDENT# if hasattr ( self , 'connection_pool' ) : #NEWLINE# #INDENT# for ( connection , old_host ) in self . connection_pool . connection_opts : #NEWLINE# #INDENT# if ( old_host == host ) : #NEWLINE# #INDENT# return connection #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# kwargs = self . kwargs . copy ( ) #NEWLINE# kwargs . update ( host ) #NEWLINE# if ( ( 'scheme' in host ) and ( host [ 'scheme' ] != self . connection_class . transport_schema ) ) : #NEWLINE# #INDENT# raise ImproperlyConfigured ( ( 'Scheme specified in connection (%s) is not the same as the connection class (%s) specifies (%s).' % ( host [ 'scheme' ] , self . connection_class . __name__ , self . connection_class . transport_schema ) ) ) #NEWLINE# #UNINDENT# return self . connection_class ( ** kwargs ) #NEWLINE# #UNINDENT# connections = map ( _create_connection , hosts ) #NEWLINE# connections = list ( zip ( connections , hosts ) ) #NEWLINE# if ( len ( connections ) == 1 ) : #NEWLINE# #INDENT# self . connection_pool = DummyConnectionPool ( connections ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . connection_pool = self . connection_pool_class ( connections , ** self . kwargs )