Receives data from websocket.

    :param request_context:

    :param bool non_blocking:

    :rtype: bytes|str

    :raises IOError: If unable to receive a message.
427640
def recv(request_context=None, non_blocking=False):
    

    if non_blocking:
        result = uwsgi.websocket_recv_nb(request_context)

    else:
        result = uwsgi.websocket_recv(request_context)

    return result
1086339
def receive_request(self, transaction):
        

        with transaction:

            transaction.separate_timer = self._start_separate_timer(transaction)

            self._blockLayer.receive_request(transaction)

            if transaction.block_transfer:
                self._stop_separate_timer(transaction.separate_timer)
                self._messageLayer.send_response(transaction)
                self.send_datagram(transaction.response)
                return

            self._observeLayer.receive_request(transaction)

            self._requestLayer.receive_request(transaction)

            if transaction.resource is not None and transaction.resource.changed:
                self.notify(transaction.resource)
                transaction.resource.changed = False
            elif transaction.resource is not None and transaction.resource.deleted:
                self.notify(transaction.resource)
                transaction.resource.deleted = False

            self._observeLayer.send_response(transaction)

            self._blockLayer.send_response(transaction)

            self._stop_separate_timer(transaction.separate_timer)

            self._messageLayer.send_response(transaction)

            if transaction.response is not None:
                if transaction.response.type == defines.Types["CON"]:
                    self._start_retransmission(transaction, transaction.response)
                self.send_datagram(transaction.response)
1140189
def send_request(self, request, callback=None, timeout=None, no_response=False):  # pragma: no cover
        
        if callback is not None:
            thread = threading.Thread(target=self._thread_body, args=(request, callback))
            thread.start()
        else:
            self.protocol.send_message(request)
            if no_response:
                return
            try:
                response = self.queue.get(block=True, timeout=timeout)
            except Empty:
                #if timeout is set
                response = None
            return response
200650
def _recv_msg(self, mid_stream=False):
        
        try:
            msgbuf = self._recv_pkt()
        except BadResource as e:
            e.mid_stream = mid_stream
            raise
        except socket.timeout as e:
            # A timeout can leave the socket in an inconsistent state because
            # it might still receive the data later and mix up with a
            # subsequent request.
            # https://github.com/basho/riak-python-client/issues/425
            raise BadResource(e, mid_stream)
        mv = memoryview(msgbuf)
        mcb = mv[0:1]
        if self.bytes_required:
            mcb = mcb.tobytes()
        try:
            msg_code, = struct.unpack("B", mcb)
        except struct.error:
            # NB: Python 2.7.3 requires this
            # http://bugs.python.org/issue10212
            msg_code, = struct.unpack("B", mv[0:1].tobytes())
            self.bytes_required = True
        data = mv[1:].tobytes()
        return (msg_code, data)
662308
def _client_receive(self):
        
        try:
            response = self._client.readline()
            self.log.debug('Snippet received: %s', response)
            return response
        except socket.error as e:
            raise Error(
                self._ad,
                'Encountered socket error reading RPC response "%s"' % e)
705914
def nonblock_recv(self):
        """"""
        self.ins.setnonblock(1)
        p = self.recv(MTU)
        self.ins.setnonblock(0)
        return p
100443
def send_request(req)
      raise StateError, "Tried to send a request while one is pending already. Make sure you read off the body." if @pending_response
      raise StateError, "Tried to send a request while a response is pending. Make sure you read off the body."  if @pending_request

      @pending_request = true

      req.stream @socket

      @pending_response = true
      @pending_request  = false
    end
892627
def receive(self):
        
        if self._closed:
            raise WebSocketError("Connection is already closed")
        try:
            return self.read_message()
        except UnicodeError as e:
            logger.info('websocket.receive: UnicodeError {}'.format(e))
            self.close(1007)
        except WebSocketError as e:
            logger.info('websocket.receive: WebSocketError {}'.format(e))
            self.close(1002)
        except Exception as e:
            logger.info('websocket.receive: Unknown error {}'.format(e))
            raise e
310042
async def handler(self, request):
        

        def task_done(future):
            self.tasks.remove(future)
            exception = future.exception()
            if exception:
                log.warning(
                    'While processing message: {0}\nDetails: {1}'.format(
                        exception,
                        traceback.format_exc())
                )

        client = web.WebSocketResponse()
        client_id = id(client)

        # upgrade to Websockets
        await client.prepare(request)

        log.info('Opening Websocket {0}'.format(id(client)))
        log.debug('Tasks: {0}'.format(self.tasks))
        log.debug('Clients: {0}'.format(self.clients))

        try:
            log.debug('Sending root info to {0}'.format(client_id))
            await client.send_json({
                '$': {'type': CONTROL_MESSAGE, 'monitor': True},
                'root': self.call_and_serialize(lambda: self.root),
                'type': self.call_and_serialize(lambda: type(self.root))
            })
            log.debug('Root info sent to {0}'.format(client_id))
        except Exception:
            log.exception('While sending root info to {0}'.format(client_id))

        try:
            self.clients[client] = self.send_worker(client)
            # Async receive client data until websocket is closed
            async for msg in client:
                task = self.loop.create_task(self.process(msg))
                task.add_done_callback(task_done)
                self.tasks += [task]
        except Exception:
            log.exception('While reading from socket:')
        finally:
            log.info('Closing WebSocket {0}'.format(id(client)))
            await client.close()
            del self.clients[client]

        return client
1011825
async def _receive(self, stream_id, pp_id, data):
        
        await self._data_channel_receive(stream_id, pp_id, data)
1273847
def receive(self, poll_interval):
        
        readable, writeable, errored = select.select(self._readlist, [], [],
                                                     poll_interval)
        for s in readable:
            data, addr = s.recvfrom(self.BUFFER_SIZE)
            if data:
                return data

        return None
725145
def receive(self, content, **kwargs):
        
        self.connection_context = DjangoChannelConnectionContext(self.message)
        self.subscription_server = DjangoChannelSubscriptionServer(graphene_settings.SCHEMA)
        self.subscription_server.on_open(self.connection_context)
        self.subscription_server.handle(content, self.connection_context)
1026713
def receive_message(self, operation, request_id):
        
        try:
            return receive_message(
                self.sock, operation, request_id, self.max_message_size)
        except BaseException as error:
            self._raise_connection_failure(error)
309724
def send(self, request):
        
        if self.call is None:
            raise ValueError("Can not send() on an RPC that has never been open()ed.")

        # Don't use self.is_active(), as ResumableBidiRpc will overload it
        # to mean something semantically different.
        if self.call.is_active():
            self._request_queue.put(request)
        else:
            # calling next should cause the call to raise.
            next(self.call)
352085
def handle(self, request, buffer_size):
        
        logger = self.logger
        msg = self.__receive(request, buffer_size)
        if msg is None:
            return False

        result = self.handler_function(msg)

        if self.component_type == StreamComponent.PROCESSOR:
            return self.__send(request, result)
        return True
954311
def _receive(self):
        
        data_in = EMPTY_BUFFER
        try:
            data_in = self._read_from_socket()
        except socket.timeout:
            pass
        except (IOError, OSError) as why:
            if why.args[0] not in (EWOULDBLOCK, EAGAIN):
                self._exceptions.append(AMQPConnectionError(why))
                self._running.clear()
        return data_in
954213
def identify_request(request: RequestType) -> bool:
    
    # noinspection PyBroadException
    try:
        data = json.loads(decode_if_bytes(request.body))
        if "@context" in data:
            return True
    except Exception:
        pass
    return False