def __manage_connections(self, ccallbacks=None):
        """This runs as the main connection management greenlet."""

        _logger.info("Running client.")

        # Create message-handler.

        if self.__message_handler_cls is not None:
# TODO(dustin): Move this to another thread if we can mix multithreading with coroutines. 
            self.__message_handler = self.__message_handler_cls(
                                        self.__election, 
                                        ccallbacks)

        # Spawn the initial connections to all of the servers.

        for (context, node) in self.__node_couplets_s:
            self.__start_connection(context, node, ccallbacks)

        # Wait for at least one connection to the server.
        self.__wait_for_one_server_connection()

        # Indicate that the client is okay to pass control back to the caller.
        self.__is_alive = True
        self.__ready_ev.set()

        # Loop, and maintain all connections. This exits when the quit event 
        # is set.
        self.__audit_connections(ccallbacks)

        # Wait for all of the connections to close. They will respond to the 
        # same quit event that terminate the audit loop just above.
        self.__join_connections()

        _logger.info("Connection management has stopped.")

        self.__is_alive = False
def __manage_connections ( self , ccallbacks = None ) : _logger . info ( "Running client." ) if self . __message_handler_cls is not None : self . __message_handler = self . __message_handler_cls ( self . __election , ccallbacks ) for ( context , node ) in self . __node_couplets_s : self . __start_connection ( context , node , ccallbacks ) self . __wait_for_one_server_connection ( ) self . __is_alive = True self . __ready_ev . set ( ) self . __audit_connections ( ccallbacks ) self . __join_connections ( ) _logger . info ( "Connection management has stopped." ) self . __is_alive = False
This runs as the main connection management greenlet.