Start the Hub connection process.

        Called when asyncio.Protocol establishes the network connection.
540672
def connection_made(self, transport):
        
        _LOGGER.info('Connection established to Hub')
        _LOGGER.debug('Transport: %s', transport)
        self.transport = transport

        self._restart_writer = True
        self.restart_writing()

        if self._aldb.status != ALDBStatus.LOADED:
            asyncio.ensure_future(self._setup_devices(), loop=self._loop)
710212
def start(self):
        
        super(BitfinexWSS, self).start()

        log.info("BitfinexWSS.start(): Initializing Websocket connection..")
        while self.conn is None:
            try:
                self.conn = create_connection(self.addr, timeout=10)
            except WebSocketTimeoutException:
                self.conn = None
                print("Couldn't create websocket connection - retrying!")

        log.info("BitfinexWSS.start(): Initializing receiver thread..")
        if not self.receiver_thread:
            self.receiver_thread = Thread(target=self.receive, name='Receiver Thread')
            self.receiver_thread.start()
        else:
            log.info("BitfinexWSS.start(): Thread not started! "
                     "self.receiver_thread is populated!")

        log.info("BitfinexWSS.start(): Initializing processing thread..")
        if not self.processing_thread:
            self.processing_thread = Thread(target=self.process, name='Processing Thread')
            self.processing_thread.start()
        else:
            log.info("BitfinexWSS.start(): Thread not started! "
                     "self.processing_thread is populated!")

        self.setup_subscriptions()
1271857
def start(self):
        """"""
        target = getattr(self._target, '__qualname__', self._target.__name__)
        self._log.debug('starting fiber {}, target {}', self.name, target)
        self._hub.run_callback(self.switch)
1273544
def start(self):
        
        self.running = True
        self.attempt_connection()
        receiver_thread = self.create_thread_fc(self.__receiver_loop)
        receiver_thread.name = "StompReceiver%s" % getattr(receiver_thread, "name", "Thread")
        self.notify('connecting')
424014
def start(self, blocking=False):
        
        self.debug("()")
        try:
            self._init_multicast_socket()
        except:
            self._multicast_socket = None
            self.exception("Failed to init multicast socket")
            raise SensorStartException("Multicast socket init failed")

        super(SensorServer, self).start(blocking=False)
        self._is_stopped.clear()
        try:
            a_thread = threading.Thread(
                target=self._thread_wrapper,
                args=(self._packet_loop,)
            )
            a_thread.daemon = True
            a_thread.start()
        except:
            self.exception("Failed to run packet loop")
            raise SensorStartException("Packet loop failed")
        self.info("Started")
        # Blocking
        super(Sensor, self).start(blocking)
557330
def on_start(self, host, port, channel, nickname, password):
        
        self.client = WebSocketIRCClient(host, port, channel, nickname,
                                         password, self)
        self.spawn(self.client.start)
1034444
void start(Future<DataPort> dataPortFuture) {
        this.startStopLock.lock();
        try {
            this.dataPortFuture = dataPortFuture;
            this.running.set(true);
            this.outgoing.resume();
            this.reconnectOutgoing.resume();
            this.stopped = connection.getExecutor().submit(this, Boolean.TRUE);
        } finally {
            this.startStopLock.unlock();
        }
    }
609756
def _connect(self):
        
        self.kik_connection_thread = Thread(target=self._kik_connection_thread_function, name="Kik Connection")
        self.kik_connection_thread.start()
672744
async def connect(self):
        
        self.reader, self.writer = await asyncio.open_connection(
            host=self.hostname,
            port=self.port,
            loop=self.loop)
        self.closed = False
        self._response_task = asyncio.ensure_future(self._response_handler())
        query = {
            "MPRPC": self.VERSION,
            "AUTH": {
                "USERNAME": self.username,
                "PASSWORD": self.password
            }
        }
        queryb = self.encoder(query)
        if self.debug is True:
            print("send auth {}".format(queryb))
        self.writer.write(queryb)
        self._login_fut = self.loop.create_future()
        self.remote_info = await self._login_fut
        if self.remote_info is False:
            raise abort(501)
        if self.heart_beat:
            self._heartbeat_task = asyncio.ensure_future(
                self._heartbeat_callback())
636242
def connect_async(self, conn_id, connection_string, callback):
        """"""

        future = self._loop.launch_coroutine(self._adapter.connect(conn_id, connection_string))
        future.add_done_callback(lambda x: self._callback_future(conn_id, x, callback))
837163
async def start(self):
        """"""

        await self.server.start()
        self.port = self.server.port
1013661
async def start_serving(self,
                            connection_config: ConnectionConfig,
                            loop: Optional[asyncio.AbstractEventLoop] = None) -> None:
        
        self.start_serving_nowait(connection_config, loop)
        await self.wait_until_serving()
740555
def start(self):
        
        if self.via_ip:
            connect_to = self.via_ip
            self.description = '[%s@%s via %s]' % (self._user,
                                                   self._hostname,
                                                   self.via_ip)
        else:
            connect_to = self._hostname
            self.description = '[%s@%s]' % (self._user,
                                            self._hostname)

        exception = None
        for i in range(60):
            try:
                self._client.connect(
                    connect_to,
                    username=self._user,
                    allow_agent=True,
                    key_filename=self._key_filename)
            # NOTE(Gonéri): TypeError is in the list because of
            # https://github.com/paramiko/paramiko/issues/615
                self._transport = self._get_transport()
            except (OSError,
                    TypeError,
                    ssh_exception.SSHException,
                    ssh_exception.NoValidConnectionsError) as e:
                exception = e
                LOG.info('%s waiting for %s: %s' %
                         (self.description, connect_to, str(exception)))
                time.sleep(1)
            else:
                LOG.debug('%s connected' % self.description)
                self._started = True
                return

        _error = ("unable to connect to ssh service on '%s': %s" %
                  (self._hostname, str(exception)))
        LOG.error(_error)
        raise exception
338077
def start(self, protocol):
        
        if self._protocol is not None:
            raise TransportError('already started')
        self._protocol = protocol
        self._protocol.connection_made(self)
        if self._readable:
            self.resume_reading()
        if self._writable:
            self._writing = True
            self._can_write.set()
571501
async def start(self):
        """"""
        if self.connection.connected:
            return

        await self.connection.connect()

        # In case credentials have been given externally (i.e. not by pairing
        # with a device), then use that client id
        if self.service.device_credentials:
            self.srp.pairing_id = Credentials.parse(
                self.service.device_credentials).client_id

        # The first message must always be DEVICE_INFORMATION, otherwise the
        # device will not respond with anything
        msg = messages.device_information(
            'pyatv', self.srp.pairing_id.decode())
        await self.send_and_receive(msg)
        self._initial_message_sent = True

        # This should be the first message sent after encryption has
        # been enabled
        await self.send(messages.set_ready_state())

        async def _wait_for_updates(_, semaphore):
            # Use a counter here whenever more than one message is expected
            semaphore.release()

        # Wait for some stuff to arrive before returning
        semaphore = asyncio.Semaphore(value=0, loop=self.loop)
        self.add_listener(_wait_for_updates,
                          protobuf.SET_STATE_MESSAGE,
                          data=semaphore,
                          one_shot=True)

        # Subscribe to updates at this stage
        await self.send(messages.client_updates_config())
        await self.send(messages.wake_device())

        try:
            await asyncio.wait_for(
                semaphore.acquire(), 1, loop=self.loop)
        except asyncio.TimeoutError:
            # This is not an issue itself, but I should do something better.
            # Basically this gives the device about one second to respond with
            # some metadata before continuing.
            pass
593228
async def async_open(self) -> None:
        """"""

        await self._loop.create_connection(
            lambda: self,
            self._host,
            self._port)
963314
def run(self):
        

        server_logger = logging.getLogger('aiohttp.server')
        # In debug mode we don't use the standard request log but a more complete in response.py
        if log.getEffectiveLevel() == logging.DEBUG:
            server_logger.setLevel(logging.CRITICAL)

        logger = logging.getLogger("asyncio")
        logger.setLevel(logging.ERROR)

        if sys.platform.startswith("win"):
            loop = asyncio.get_event_loop()
            # Add a periodic callback to give a chance to process signals on Windows
            # because asyncio.add_signal_handler() is not supported yet on that platform
            # otherwise the loop runs outside of signal module's ability to trap signals.

            def wakeup():
                loop.call_later(0.5, wakeup)
            loop.call_later(0.5, wakeup)

        server_config = Config.instance().get_section_config("Server")

        ssl_context = None
        if server_config.getboolean("ssl"):
            if sys.platform.startswith("win"):
                log.critical("SSL mode is not supported on Windows")
                raise SystemExit
            ssl_context = self._create_ssl_context(server_config)

        self._loop = asyncio.get_event_loop()

        if log.getEffectiveLevel() == logging.DEBUG:
            # On debug version we enable info that
            # coroutine is not called in a way await/yield from
            self._loop.set_debug(True)

        for key, val in os.environ.items():
            log.debug("ENV %s=%s", key, val)

        self._app = aiohttp.web.Application()
        # Background task started with the server
        self._app.on_startup.append(self._on_startup)

        # Allow CORS for this domains
        cors = aiohttp_cors.setup(self._app, defaults={
            # Default web server for web gui dev
            "http://127.0.0.1:8080": aiohttp_cors.ResourceOptions(expose_headers="*", allow_headers="*"),
            "http://localhost:8080": aiohttp_cors.ResourceOptions(expose_headers="*", allow_headers="*"),
            "http://127.0.0.1:4200": aiohttp_cors.ResourceOptions(expose_headers="*", allow_headers="*"),
            "http://localhost:4200": aiohttp_cors.ResourceOptions(expose_headers="*", allow_headers="*"),
            "http://gns3.github.io": aiohttp_cors.ResourceOptions(expose_headers="*", allow_headers="*"),
            "https://gns3.github.io": aiohttp_cors.ResourceOptions(expose_headers="*", allow_headers="*")
        })

        PortManager.instance().console_host = self._host

        for method, route, handler in Route.get_routes():
            log.debug("Adding route: {} {}".format(method, route))
            cors.add(self._app.router.add_route(method, route, handler))
        for module in MODULES:
            log.debug("Loading module {}".format(module.__name__))
            m = module.instance()
            m.port_manager = PortManager.instance()

        log.info("Starting server on {}:{}".format(self._host, self._port))

        self._handler = self._app.make_handler()
        if self._run_application(self._handler, ssl_context) is False:
            self._loop.stop()
            return

        self._signal_handling()
        self._exit_handling()

        if server_config.getboolean("shell"):
            asyncio.async(self.start_shell())

        try:
            self._loop.run_forever()
        except TypeError as e:
            # This is to ignore an asyncio.windows_events exception
            # on Windows when the process gets the SIGBREAK signal
            # TypeError: async() takes 1 positional argument but 3 were given
            log.warning("TypeError exception in the loop {}".format(e))
        finally:
            if self._loop.is_running():
                self._loop.run_until_complete(self.shutdown_server())