binary messages come in two parts; wait until we've received both
167949
function checkBinaryReady(uuid) {
      if (!(uuid in api._blobs && uuid in api._binaryMessages)) {
        return;
      }
      log('receive full binary message', uuid);
      var blob = api._blobs[uuid];
      var msg = api._binaryMessages[uuid];

      delete api._blobs[uuid];
      delete api._binaryMessages[uuid];

      var blobToDeliver;
      if (isBrowser) {
        blobToDeliver = blobUtil.createBlob([blob], {type: msg.contentType});
      } else {
        blobToDeliver = blob;
        blob.type = msg.contentType; // non-standard, but we do it for the tests
      }

      msg.cb(null, blobToDeliver);
    }
482731
def wait(self, duration=None, count=0):
        
        start = time.time()
        total = 0
        while True:
            type, result = self._recv(MSG, PING, OK)
            if type is MSG:
                total += 1
                if self._handle_msg(result) is False:
                    break

                if count and total >= count:
                    break

            elif type is PING:
                self._handle_ping()

            if duration and time.time() - start > duration:
                break
430350
private static byte doEncodeOpcode(byte b, WsMessage message) {
        Kind kind = message.getKind();

        switch (kind) {
        case CONTINUATION:
            b |= Opcode.CONTINUATION.getCode();
            break;
        case TEXT: {
        	b |= Opcode.TEXT.getCode();
        	break;
        }
        case BINARY: {
        	b |= Opcode.BINARY.getCode();
        	break;
        }
        case PING: {
        	b |= Opcode.PING.getCode();
        	break;
        }
        case PONG: {
        	b |= Opcode.PONG.getCode();
        	break;
        }
        case CLOSE: {
        	b |= Opcode.CLOSE.getCode();
        	break;
        }
        default:
            throw new IllegalStateException("Unrecognized frame type: " + message.getKind());
        }
        return b;
    }
100306
def valid_body_waiting(self):
        
        # 0f f8 be 04 00 08 00 00 2f 04
        packet_size = velbus.MINIMUM_MESSAGE_SIZE + \
            (self.buffer[3] & 0x0F)
        if len(self.buffer) < packet_size:
            self.logger.debug("Buffer does not yet contain full message")
            result = False
        else:
            result = True
            result = result and self.buffer[packet_size - 1] == velbus.END_BYTE
            if not result:
                self.logger.warning("End byte not recognized")
            result = result and velbus.checksum(
                self.buffer[0:packet_size - 2])[0] == self.buffer[packet_size - 2]
            if not result:
                self.logger.warning("Checksum not recognized")
        self.logger.debug("Valid Body Waiting: %s (%s)", result, str(self.buffer))
        return result
1258563
def _wait_receive_msg(self, timeout=0.25, type=2):
        """"""
        stamp = time.monotonic()
        while (time.monotonic() - stamp) < timeout:
            try:
                message = self._mq.receive(block=False, type=2)
                return message
            except sysv_ipc.BusyError:
                time.sleep(0.001) # wait a bit then retry!
        # uh-oh timed out
        raise RuntimeError("Timed out waiting for PulseIn message")
2603
def _get_message(self, block=True, timeout=0.1, get_partition_info=None,
                     update_offset=True):
        
        start_at = time.time()
        while self.queue.empty():
            # We're out of messages, go grab some more.
            log.debug('internal queue empty, fetching more messages')
            with FetchContext(self, block, timeout):
                self._fetch()

            if not block or time.time() > (start_at + timeout):
                break

        try:
            partition, message = self.queue.get_nowait()

            if update_offset:
                # Update partition offset
                self.offsets[partition] = message.offset + 1

                # Count, check and commit messages if necessary
                self.count_since_commit += 1
                self._auto_commit()

            if get_partition_info is None:
                get_partition_info = self.partition_info
            if get_partition_info:
                return partition, message
            else:
                return message
        except queue.Empty:
            log.debug('internal queue empty after fetch - returning None')
            return None
1126760
private static byte doEncodeOpcode(byte b, WsMessage message) {
        switch (message.getKind()) {
        case TEXT: {
            b |= Opcode.TEXT.getCode();
            break;
        }
        case BINARY: {
            b |= Opcode.BINARY.getCode();
            break;
        }
        case PING: {
            b |= Opcode.PING.getCode();
            break;
        }
        case PONG: {
            b |= Opcode.PONG.getCode();
            break;
        }
        case CLOSE: {
            b |= Opcode.CLOSE.getCode();
            break;
        }
        default:
            throw new IllegalArgumentException("Unrecognized frame type: " + message.getKind());
        }
        return b;
    }
382112
def check(self, order, sids):
        '''  '''
        payload = "{}"
        #TODO store hashes {'intuition': {'id1': value, 'id2': value}}
        # Block self.timeout seconds on self.channel for a message
        raw_msg = self.client.blpop(self.channel, timeout=self.timeout)
        if raw_msg:
            _, payload = raw_msg

            msg = json.loads(payload.replace("'", '"'), encoding='utf-8')
            for sid in msg.keys():
                #TODO Harmonize lower() and upper() symbols
                if sid.lower() in map(str.lower, sids):
                    print('ordering {} of {}'.format(msg[sid], sid))
                    #order(sid.upper(), msg[sid])
                    order(sid, msg[sid])
                else:
                    print('skipping unknown symbol {}'.format(sid))
139696
def wait_one(self):
        """"""
        while True:
            try:
                item = self.output_queue.get(True, self.polltime)
            except Queue.Empty:
                continue
            except KeyboardInterrupt:
                LOGGER.debug('Exiting')
                return
            else:
                item.check_result()
                return
599183
def wait_until(message='completed!')
      3.times { dot_and_sleep(1) }
      begin
        dot_and_sleep(2) until yield
      rescue Excon::Errors::SocketError => e
        # print out the error so the user can interrupt if necessary
        print "#{e.class}: #{e.message}! Retry:"
        sleep(1)
        retry
      end
      puts message
    end
382573
def message_from_binary_file(fp, *args, **kws):
    
    from future.backports.email.parser import BytesParser
    return BytesParser(*args, **kws).parse(fp)
1367095
function( data ) {
   
            
            var read_buffer = read_buffers_by_connection[tcp_connection];
            read_buffer += data;

            //split by new lines, 
            var messages = read_buffer.split('\n');
            
            //last element is either a partial message, or ''            
            read_buffer = messages.pop();
        
            for ( var i = 0; i < messages.length; i++ ) {
                
                //TODO error handling
                var message = messages[i];
                var components = message.split( ' ' );
                var path = components[0];
                var value = components[1];
                var timestamp = components[2];
                
                that.emit(  path, value, timestamp );                
            }            
        }
564756
async def send(self, message: Union[str, bytes],
                   binary: bool=False,
                   compress: Optional[int]=None) -> None:
        """"""
        if isinstance(message, str):
            message = message.encode('utf-8')
        if binary:
            await self._send_frame(message, WSMsgType.BINARY, compress)
        else:
            await self._send_frame(message, WSMsgType.TEXT, compress)
989231
def send(self, message, binary=False):
        
        if not self.is_closed:
            self.session.send_message(message, binary=binary)
53275
def Binary(x):
    """"""
    if isinstance(x, text_type) and not (JYTHON or IRONPYTHON):
        return x.encode()
    return bytes(x)
676331
def retrbinary(cmd, blocksize, rest_offset = nil) # :yield: data
      synchronize do
        with_binary(true) do
          begin
            conn = transfercmd(cmd, rest_offset)
            loop do
              data = conn.read(blocksize)
              break if data == nil
              yield(data)
            end
            conn.shutdown(Socket::SHUT_WR)
            conn.read_timeout = 1
            conn.read
          ensure
            conn.close if conn
          end
          voidresp
        end
      end
    end
772044
def precheck():
    
    binaries = ['make']
    for bin in binaries:
        if not which(bin):
            msg = 'Dependency fail -- Unable to locate rquired binary: '
            stdout_message('%s: %s' % (msg, ACCENT + bin + RESET))
            return False
        elif not root():
            return False
    return True