Start waiting for a valid handshake.
551761
public void startWaitForHandshake() {
        if (log.isDebugEnabled()) {
            log.debug("startWaitForHandshake - {}", sessionId);
        }
        // start the handshake checker after maxHandshakeTimeout milliseconds
        if (scheduler != null) {
            try {
                waitForHandshakeTask = scheduler.schedule(new WaitForHandshakeTask(), new Date(System.currentTimeMillis() + maxHandshakeTimeout));
            } catch (TaskRejectedException e) {
                log.error("WaitForHandshake task was rejected for {}", sessionId, e);
            }
        }
    }
524092
def start(self):
        '''
        
        '''
        # Start suicide polling thread
        log.debug('Starting the auth process')
        self.verify_cert()
        self._create_skt()
        log.debug('The auth process can receive at most %d parallel connections', AUTH_MAX_CONN)
        self.socket.listen(AUTH_MAX_CONN)
        thread = threading.Thread(target=self._suicide_when_without_parent, args=(os.getppid(),))
        thread.start()
        signal.signal(signal.SIGTERM, self._exit_gracefully)
        self.__up = True
        while self.__up:
            try:
                (clientsocket, address) = self.socket.accept()
                wrapped_auth_skt = ssl.wrap_socket(clientsocket,
                                                   server_side=True,
                                                   certfile=self.certificate,
                                                   keyfile=self.keyfile)
            except ssl.SSLError:
                log.exception('SSL error', exc_info=True)
                continue
            except socket.error as error:
                if self.__up is False:
                    return
                else:
                    msg = 'Received auth socket error: {}'.format(error)
                    log.error(msg, exc_info=True)
                    raise NapalmLogsExit(msg)
            log.info('%s connected', address)
            log.debug('Starting the handshake')
            client_thread = threading.Thread(target=self._handshake,
                                             args=(wrapped_auth_skt, address))
            client_thread.start()
352336
def wait_send(self, timeout = None):
		""""""
		self._send_queue_cleared.clear()
		self._send_queue_cleared.wait(timeout = timeout)
179626
def wait_return(self, callback):
        """"""
        if self.check_recv():
            return callback(self)
        _t = threading.Thread(target=self._wait_non_ressources, args=(callback,))  # noqa: E501
        _t.setDaemon(True)
        _t.start()
948613
async def ws_handler(self, protocol, path):
        
        self.handshake_completed_event.set()
        await self.closed_event.wait()
426553
def connect(self, address):
        
        self.sock.connect(address)
        ClientHandshake(self).perform()
        self.handshake_sent = True
619897
def wait(self):
        """"""
        logging.info("waiting for {} jobs to complete".format(len(self.submissions)))
        while not self.shutdown:
            time.sleep(1)
429712
def handshake(timeout, sam_api, max_version):
    """"""
    sock = controller_connect(sam_api, timeout=timeout)
    response = sam_cmd(sock, greet(max_version))
    if response.ok:
        return sock
    else:
        raise HandshakeError("Failed to handshake with SAM: %s" % repr(response))
658110
def initiate_handshake(self, headers, timeout=None):
        
        io_loop = IOLoop.current()
        timeout = timeout or DEFAULT_INIT_TIMEOUT_SECS

        self.writer.put(messages.InitRequestMessage(
            version=PROTOCOL_VERSION,
            headers=headers
        ))

        init_res_future = self.reader.get()
        timeout_handle = io_loop.call_later(timeout, (
            lambda: init_res_future.set_exception(errors.TimeoutError(
                'Handshake with %s:%d timed out. Did not receive an INIT_RES '
                'after %s seconds' % (
                    self.remote_host, self.remote_host_port, str(timeout)
                )
            ))
        ))
        io_loop.add_future(
            init_res_future,
            (lambda _: io_loop.remove_timeout(timeout_handle)),
        )

        init_res = yield init_res_future
        if init_res.message_type != Types.INIT_RES:
            raise errors.UnexpectedError(
                "Expected handshake response, got %s" % repr(init_res)
            )
        self._extract_handshake_headers(init_res)
        self._handshake_performed = True

        # The receive loop is started only after the handshake has been
        # completed.
        self._loop()

        raise tornado.gen.Return(init_res)
1174548
async def _wait_execute(self, address, command, args, kw):
        """"""
        conn = await self.acquire(command, args)
        try:
            return (await conn.execute(command, *args, **kw))
        finally:
            self.release(conn)
90579
async def wait(self, container = None):
        '''
        
        '''
        if hasattr(self, '_result'):
            if hasattr(self, '_exception'):
                raise self._exception
            else:
                return self._result
        else:
            ev = await FutureEvent.createMatcher(self)
            if hasattr(ev, 'exception'):
                raise ev.exception
            else:
                return ev.result
547382
def wait_for_confirmation(provider, transaction_id):
    ''
    while(True):
        transaction = provider.gettransaction(transaction_id)
        if transaction["confirmations"] > 0:
            break
        time.sleep(10)
1081852
def HandleVerack(self):
        """"""
        m = Message('verack')
        self.SendSerializedMessage(m)
        self.leader.NodeCount += 1
        self.identifier = self.leader.NodeCount
        logger.debug(f"{self.prefix} Handshake complete!")
        self.handshake_complete = True
        self.ProtocolReady()
88796
def wait_on_receipt(self):
        
        with self.receipt_condition:
            while not self.received:
                self.receipt_condition.wait()
        self.received = False
941480
def wait(self, seconds=None, **kw):
        ''
        # Use ping/pong to unblock recv for polling transport
        self._heartbeat_thread.hurry()
        # Use timeout to unblock recv for websocket transport
        self._transport.set_timeout(seconds=1)
        # Listen
        warning_screen = self._yield_warning_screen(seconds)
        for elapsed_time in warning_screen:
            if self._should_stop_waiting(**kw):
                break
            try:
                try:
                    self._process_packets()
                except TimeoutError:
                    pass
                except KeyboardInterrupt:
                    self._close()
                    raise
            except ConnectionError as e:
                self._opened = False
                try:
                    warning = Exception('[connection error] %s' % e)
                    warning_screen.throw(warning)
                except StopIteration:
                    self._warn(warning)
                try:
                    namespace = self.get_namespace()
                    namespace._find_packet_callback('disconnect')()
                except PacketError:
                    pass
        self._heartbeat_thread.relax()
        self._transport.set_timeout()
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
955016
def do_handshake(self, callback=None):
        
        if self._state != self.S_UNWRAPPED:
            raise RuntimeError('handshake in progress or completed')
        self._sslobj = sslcompat.wrap_bio(self._context, self._incoming, self._outgoing,
                                          self._server_side, self._server_hostname)
        self._state = self.S_DO_HANDSHAKE
        self._handshake_cb = callback
        ssldata, appdata = self.feed_ssldata(b'')
        assert len(appdata) == 0
        return ssldata