Connect to all the appropriate instances
971199
def check_connections(self):
        ''''''
        logger.info('Checking connections')
        if self._lookupd:
            self.discover(self._topic)

        # Make sure we're connected to all the prescribed hosts
        for hostspec in self._nsqd_tcp_addresses:
            logger.debug('Checking nsqd instance %s', hostspec)
            host, port = hostspec.split(':')
            port = int(port)
            conn = self._connections.get((host, port), None)
            # If there is no connection to it, we have to try to connect
            if not conn:
                logger.info('Connecting to %s:%s', host, port)
                self.connect(host, port)
            elif not conn.alive():
                # If we've connected to it before, but it's no longer alive,
                # we'll have to make a decision about when to try to reconnect
                # to it, if we need to reconnect to it at all
                if conn.ready_to_reconnect():
                    logger.info('Reconnecting to %s:%s', host, port)
                    if conn.connect():
                        conn.setblocking(0)
                        self.reconnected(conn)
            else:
                logger.debug('Checking freshness')
                now = time.time()
                time_check = math.ceil(now - self.last_recv_timestamp)
                if time_check >= ((self.heartbeat_interval * 2) / 1000.0):
                    if conn.ready_to_reconnect():
                        logger.info('Reconnecting to %s:%s', host, port)
                        if conn.connect():
                            conn.setblocking(0)
                            self.reconnected(conn)
1174405
def connect(self, protocol=None):
        """"""
        self._link.enter_debug(STLink.Protocol.SWD)
        self._is_connected = True
565210
function() {
        try {
          var server = {
            "host": params.host,
            "port": params.port,
            "timeout": params.timeout || 20000,
            "connectHeaders": {
              "host": "/",
              "login": params.username,
              "passcode": params.password,
              "heart-beat": "5000, 5000"
            }
          };

          var servers = [server];

          var reconnectOptions = {
            'maxReconnects': 20
          };

          var manager = new Stompit.ConnectFailover(servers, reconnectOptions);

          manager.connect(function(error, stompClient, reconnect) {
            if (error) {
              fireEvent("error", {
                errorCode: error.code,
                errorMessage: error.message,
                errorEvent: error
              });

              return;
            }

            client = stompClient;

            client.on('error', function(error) {
              fireEvent("error", {
                errorCode: 999,
                errorMessage: "ActiveMQ client has had an error",
                errorEvent: error
              });
              reconnect();
            });

            fireEvent("init");
          });

        } catch (error) {
          console.error(error);
        }
      }
52966
def connect(self, their_unl, events, force_master=1, hairpin=1,
                nonce="0" * 64):
        
        parms = (their_unl, events, force_master, hairpin, nonce)
        t = Thread(target=self.connect_handler, args=parms)
        t.start()
        self.unl_threads.append(t)
542025
def connect(self):
        
        logger.info("Connecting to %s:%s", self._host, self._port)
        reader, writer = yield from asyncio.open_connection(
                self._host, self._port, loop=self._loop)
        self._ioloop_future = ensure_future(
                self._ioloop(reader, writer), loop=self._loop)
        logger.info("Connected")
268731
def connect_all(state):
    '''
    
    '''

    hosts = [
        host for host in state.inventory
        if state.is_host_in_limit(host)
    ]

    greenlet_to_host = {
        state.pool.spawn(host.connect, state): host
        for host in hosts
    }

    with progress_spinner(greenlet_to_host.values()) as progress:
        for greenlet in gevent.iwait(greenlet_to_host.keys()):
            host = greenlet_to_host[greenlet]
            progress(host)

    # Get/set the results
    failed_hosts = set()

    for greenlet, host in six.iteritems(greenlet_to_host):
        # Raise any unexpected exception
        greenlet.get()

        if host.connection:
            state.activate_host(host)
        else:
            failed_hosts.add(host)

    # Remove those that failed, triggering FAIL_PERCENT check
    state.fail_hosts(failed_hosts, activated_count=len(hosts))
788327
def connectRelay(self):
        
        self.protocol = self.connector.buildProtocol(None)
        self.connected = True
        self.protocol.makeConnection(self)
847109
def connect(self):
        
        logging.info("Connecting to {} with user {}.".format(self.host, self.username))
        credentials = pika.PlainCredentials(self.username, self.password)
        connection_params = pika.ConnectionParameters(host=self.host,
                                                      credentials=credentials,
                                                      heartbeat_interval=self.heartbeat_interval)
        self.connection = pika.BlockingConnection(connection_params)
874418
def connect(self, ctrl):
        """"""
        if self.prompt:
            self.prompt_re = self.driver.make_dynamic_prompt(self.prompt)
        else:
            self.prompt_re = self.driver.prompt_re

        self.ctrl = ctrl
        if self.protocol.connect(self.driver):
            if self.protocol.authenticate(self.driver):
                self.ctrl.try_read_prompt(1)
                if not self.prompt:
                    self.prompt = self.ctrl.detect_prompt()

                if self.is_target:
                    self.update_config_mode()
                    if self.mode is not None and self.mode != 'global':
                        self.last_error_msg = "Device is not in global mode. Disconnected."
                        self.chain.disconnect()
                        return False

                self.prompt_re = self.driver.make_dynamic_prompt(self.prompt)
                self.connected = True

                if self.is_target is False:
                    if self.os_version is None:
                        self.update_os_version()

                    self.update_hostname()
                else:
                    self._connected_to_target()
                return True

        else:
            self.connected = False
            return False
407683
async def connect(self, **kwargs):
        
        kwargs.setdefault('loop', self.loop)
        kwargs.setdefault('max_frame_size', self.max_frame_size)
        kwargs.setdefault('bakery_client', self.bakery_client)
        if 'macaroons' in kwargs:
            if not kwargs['bakery_client']:
                kwargs['bakery_client'] = httpbakery.Client()
            if not kwargs['bakery_client'].cookies:
                kwargs['bakery_client'].cookies = GoCookieJar()
            jar = kwargs['bakery_client'].cookies
            for macaroon in kwargs.pop('macaroons'):
                jar.set_cookie(go_to_py_cookie(macaroon))
        self._connection = await Connection.connect(**kwargs)
1176567
def connect(self, sid, namespace):
        """"""
        self.enter_room(sid, namespace, None)
        self.enter_room(sid, namespace, sid)
542616
def connect(self):
        
        jobs = []
        self._socket.connect((self.host, self.port))
        try:
            jobs = [spawn(self._recv_loop), spawn(self._send_loop)]
            joinall(jobs)
        finally:
            killall(jobs)
449083
def connect_signals(self):
        
        for task in self:
            dispatcher.connect(self.on_ok, signal=task.S_OK, sender=task)
38877
def connect!
      # Keep existing connections
      return unless @backend.nil?
      @backend = train_connection.connection
      @backend.wait_until_ready

      # When the testing function `mock_instance` is used, it will set
      # this instance variable to false and handle this function call
      # after the platform data is mocked; this will allow binding
      # of mixin functions based on the mocked platform.
      mix_in_target_platform! unless @mocked_connection
    rescue Train::UserError => e
      raise ConnectionFailure.new(e, config)
    rescue Train::Error => e
      # These are typically wrapper errors for other problems,
      # so we'll prefer to use e.cause over e if available.
      raise ConnectionFailure.new(e.cause || e, config)
    end
79195
async def do_connect(self, args):
        
        params = args.split()
        device = '/dev/ttyUSB0'
        workdir = None

        try:
            device = params[0]
        except IndexError:
            if self.tools.device:
                device = self.tools.device
        try:
            workdir = params[1]
        except IndexError:
            if self.tools.workdir:
                workdir = self.tools.workdir

        if device:
            await self.tools.connect(False, device=device, workdir=workdir)
        _LOGGING.info('Connection complete.')
1123492
def connect(self, *args):
        """"""

        self.log("Connect ", args, lvl=verbose)

        try:
            sock = args[0]
            ip = args[1]

            if sock not in self._sockets:
                self.log("New client connected:", ip, lvl=debug)
                clientuuid = str(uuid4())
                self._sockets[sock] = Socket(ip, clientuuid)
                # Key uuid is temporary, until signin, will then be replaced
                #  with account uuid

                self._clients[clientuuid] = Client(
                    sock=sock,
                    ip=ip,
                    clientuuid=clientuuid,
                )

                self.log("Client connected:", clientuuid, lvl=debug)
            else:
                self.log("Old IP reconnected!", lvl=warn)
                #     self.fireEvent(write(sock, "Another client is
                # connecting from your IP!"))
                #     self._sockets[sock] = (ip, uuid.uuid4())
        except Exception as e:
            self.log("Error during connect: ", e, type(e), lvl=critical)
681578
def connect
      log("connect")
      ret = Lib::Rados.rados_connect(handle)
      raise SystemCallError.new("connect to cluster failed", -ret) if ret < 0
    end