Yield packets until a Close packet is received.
6046
def ReadUntilClose(self):
        """"""
        while True:
            cmd, data = self.ReadUntil(b'CLSE', b'WRTE')
            if cmd == b'CLSE':
                self._Send(b'CLSE', arg0=self.local_id, arg1=self.remote_id)
                break
            if cmd != b'WRTE':
                if cmd == b'FAIL':
                    raise usb_exceptions.AdbCommandFailureException(
                        'Command failed.', data)
                raise InvalidCommandError('Expected a WRITE or a CLOSE, got %s (%s)',
                                          cmd, data)
            yield data
485341
def _send_packet(self, data):
        
        if self._closed:
            return

        data = json.dumps(data)

        def send():
            try:
                yield From(self.pipe_connection.write(data))
            except BrokenPipeError:
                self.detach_and_close()
        ensure_future(send())
846488
def _on_open(self, _):
        """"""
        nick = self._format_nick(self._nick, self._pwd)
        data = {"cmd": "join", "channel": self._channel, "nick": nick}
        self._send_packet(data)
        self._thread = True
        threading.Thread(target=self._ping).start()
312328
def later(timeout, f, *args, **kwargs):
    '''
    
    '''
    def wrap(*args, **kwargs):
        sleep(timeout)
        return f(*args, **kwargs)

    return spawn(wrap, *args, **kwargs)
660203
function(packet) {
        packet.commandId = packet.readInt();
        packet.command = packet.commandId === 0
            ? 'return'
            : 'close';
        this.emit('osk_command', packet);
    }
244642
def managed_process(process):
    """"""
    try:
        yield process
    finally:
        for stream in [process.stdout, process.stdin, process.stderr]:
            if stream:
                stream.close()
        process.wait()
8673
def socket(self, blocking=True):
        ''''''
        # If the socket is available, then yield it. Otherwise, yield nothing
        if self._socket_lock.acquire(blocking):
            try:
                yield self._socket
            finally:
                self._socket_lock.release()
329347
def read(self):
        
        """
        # Read until we have a \0 in our buffer.
        while b'\0' not in self._recv_buffer:
            self._recv_buffer += yield From(_read_chunk_from_socket(self.socket))

        # Split on the first separator.
        pos = self._recv_buffer.index(b'\0')

        packet = self._recv_buffer[:pos]
        self._recv_buffer = self._recv_buffer[pos + 1:]

        raise Return(packet)
597191
def forward_packet(self, writer, packet, raw_packet):
        """"""
        peer = writer.get_extra_info('peername')
        log.debug(' %s:%s: forwarding data: %s', peer[0], peer[1], packet)
        if 'command' in packet:
            packet_id = serialize_packet_id(packet)
            command = packet['command']
            ack = yield from self.protocol.send_command_ack(
                packet_id, command)
            if ack:
                writer.write("20;00;OK;".encode() + CRLF)
            for _ in range(DEFAULT_SIGNAL_REPETITIONS-1):
                yield from self.protocol.send_command_ack(
                    packet_id, command)
        else:
            self.protocol.send_raw_packet(raw_packet)
1371190
def _tcpdump_callback(self, line, kill_switch):
    """"""

    line = line.lower()
    if ("listening" in line) or ("reading" in line):
        self.started = True
    if ("no suitable device" in line):
        self.error = True
        self.kill_switch()
    if "by kernel" in line:
        self.stopped = True
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()
1062080
def read_packet(self, timeout=3.0):
        """"""

        try:
            return self.queue.get(timeout=timeout)
        except Empty:
            raise InternalTimeoutError("Timeout waiting for packet in AsyncPacketBuffer")
422470
private void checkIfLastPacketTimeout() {
     synchronized (ackQueue) {
             if( !ackQueue.isEmpty()  && (
                             System.currentTimeMillis() - lastPacketSentTime > packetTimeout) ) {
               DFSClient.LOG.warn("Packet " + ackQueue.getLast().seqno +
                             " of " + block + " is timed out");
             }
     }
  }
691478
function() {
    const err = Errors.createError(
      'socket timeout',
      true,
      info,
      '08S01',
      Errors.ER_SOCKET_TIMEOUT
    );
    const packetMsgs = info.getLastPackets();
    if (packetMsgs !== '') {
      err.message = err.message + '\nlast received packets:\n' + packetMsgs;
    }
    _fatalError(err, true);
  }
284471
def handle(self, pkt, raddress, rport):
        """"""
        log.debug("In TftpStateServerStart.handle")
        if isinstance(pkt, TftpPacketRRQ):
            log.debug("Handling an RRQ packet")
            return TftpStateServerRecvRRQ(self.context).handle(pkt,
                                                               raddress,
                                                               rport)
        elif isinstance(pkt, TftpPacketWRQ):
            log.debug("Handling a WRQ packet")
            return TftpStateServerRecvWRQ(self.context).handle(pkt,
                                                               raddress,
                                                               rport)
        else:
            self.sendError(TftpErrors.IllegalTftpOp)
            raise TftpException("Invalid packet to begin up/download: %s" % pkt)
892447
def backoff_generator(self):
        """"""
        for x in self.config.backoff_delays:
            yield x
        while True:
            yield self.config.backoff_delays[-1]
28968
def send_exit(cls, sock, payload=b''):
    """"""
    cls.write_chunk(sock, ChunkType.EXIT, payload)