Send a message and wait for a response.
16704
async def send_and_receive(self, message,
                               generate_identifier=True, timeout=5):
        """"""
        await self._connect_and_encrypt()

        # Some messages will respond with the same identifier as used in the
        # corresponding request. Others will not and one example is the crypto
        # message (for pairing). They will never include an identifer, but it
        # it is in turn only possible to have one of those message outstanding
        # at one time (i.e. it's not possible to mix up the responses). In
        # those cases, a "fake" identifier is used that includes the message
        # type instead.
        if generate_identifier:
            identifier = str(uuid.uuid4())
            message.identifier = identifier
        else:
            identifier = 'type_' + str(message.type)

        self.connection.send(message)
        return await self._receive(identifier, timeout)
477312
def send_message(self, message):
        
        if self.connected:
            self.send(
                json.dumps(message.request))
1063348
def wait_response(self):
        ''''''
        responses = self.read()
        while not responses:
            responses = self.read()
        return responses
1318818
def send_wait(self,text):
	""""""
	self.send(text)
	time.sleep(len(text)*PiLite.COLS_PER_CHAR*self.speed/1000.0)
927571
async def message(request):
    

    msg = request.get('msg')
    if msg is None:
        return request.text("To send a message, go to 0.0.0.0:8000/"
                            "message/?msg='insert message here'.")
    await app.webhook.send(msg)
    return response.text("Send.")
239730
def send_response(self, code, message=None):
        """"""
        self.log_request(code)
        if message is None:
            message = code in self.responses and self.responses[code][0] or ""
        if self.request_version != "HTTP/0.9":
            hdr = "%s %d %s\r\n" % (self.protocol_version, code, message)
            self.wfile.write(hdr.encode("ascii"))
834596
def send(self, msg):
        """"""
        debug('sent %s', msg)
        self.loop.send(self._packer.pack(msg))
1176635
def send(self, message):
        
        if isinstance(message, dict):
            response = self.client.mail.send.post(request_body=message)
        else:
            response = self.client.mail.send.post(request_body=message.get())
        return response
1315610
def send(self, msg):
        """"""
        if self._conn:
            self._conn.write_data(msg.message, msg.response_command)
1028237
def wait(self, timeout=None):
        """"""
        self._event.wait(timeout)
        return self._event.isSet()
970237
def wait_for_reply(user_id, timeout)
      # We only want the reply to the supplied message_id, so set filter on message id
      filter = "#{Java::org.hornetq.api.core::FilterConstants::HORNETQ_USERID} = 'ID:#{user_id}'" if user_id
      @session.consumer(:queue_name => @reply_queue, :filter=>filter) do |consumer|
        consumer.receive(timeout)
      end
    end
1135928
String waitAndGetMessage() {
    synchronized (this) {
      // Wait for a message to send.
      while (this.statusMessagesToSend.isEmpty()) {
        try {
          this.wait();
        } catch (final InterruptedException e) {
          LOG.log(Level.FINE, "Interrupted. Ignoring.");
        }
      }

      // Send the message
      return getMessageForStatus(this.statusMessagesToSend.poll());
    }
  }
70953
public void onReceive(Object message) {

        // Start all workers
        if (message instanceof RequestToBatchSenderAsstManager) {

            // clear responseMap

            RequestToBatchSenderAsstManager request = (RequestToBatchSenderAsstManager) message;
            originalManager = getSender();
            taskId = request.getTaskId();
            asstManagerRetryIntervalMillis = request
                    .getAsstManagerRetryIntervalMillis();
            // assumption: at least 12
            taskIdTrim = taskId.length() <= 12 ? taskId
                    : taskId.substring(taskId.length() - 12,
                            taskId.length());
            workers = request.getWorkers();
            maxConcurrencyAdjusted = request.getMaxConcurrency();

            requestTotalCount = workers.size();

            sendMessageUntilStopCount(maxConcurrencyAdjusted);

            // if not completed; will schedule a continue send msg
            if (processedWorkerCount < requestTotalCount) {

                waitAndRetry();
                return;
            } else {
                logger.info("Now finished sending all needed messages. Done job of ASST Manager at "
                        + PcDateUtils.getNowDateTimeStrStandard());
                return;
            }
        } else if (message instanceof ContinueToSendToBatchSenderAsstManager) {

            // now reaching the end; have processed all of them, just waiting
            // the response to come back
            int notProcessedNodeCount = requestTotalCount
                    - processedWorkerCount;
            if (notProcessedNodeCount <= 0) {
                logger.info("!Finished sending all msg in ASST MANAGER at "
                        + PcDateUtils.getNowDateTimeStrStandard()

                        + " STOP doing wait and retry.");
                return;
            }

            int extraSendCount = maxConcurrencyAdjusted
                    - (processedWorkerCount - responseCount);

            if (extraSendCount > 0) {
                logger.info("HAVE ROOM to send extra of : " + extraSendCount
                        + " MSG. now Send at "
                        + PcDateUtils.getNowDateTimeStrStandard());

                sendMessageUntilStopCount(processedWorkerCount + extraSendCount);
                waitAndRetry();
            } else {
                logger.info("NO ROOM to send extra. Windowns is full. extraSendCount is negative: "
                        + extraSendCount
                        + " reschedule now at "
                        + PcDateUtils.getNowDateTimeStrStandard());
                waitAndRetry();

            }
        } else if (message instanceof ResponseCountToBatchSenderAsstManager) {

            responseCount = ((ResponseCountToBatchSenderAsstManager) message)
                    .getResponseCount();

            logger.debug("RECV IN batchSenderAsstManager FROM ExecutionManager responseCount: "
                    + responseCount);

        }
    }
1075227
def req(self, message_id, timeout):
        ''''''
        return self.send(constants.REQ + ' ' + message_id + ' ' + str(timeout))
285830
async def send(self, *args, **kwargs):
        """"""
        for callback in self:
            res = callback(*args, **kwargs)
            if asyncio.iscoroutine(res) or isinstance(res, asyncio.Future):
                await res
865870
def create_response(self, message, sign):
        
        def _response(code=200, data=None):
            """
            _response
            """
            resp_msg = message.to_response(code=code, data=data, sign=sign)

            with self._session.session_lock:
                mid = self._conn.publish(topic="/controller",
                                         qos=0, payload=resp_msg.to_dict())
                session = self._session.create(resp_msg, mid=mid, age=10)
            logging.debug("sending response as mid: %s" % mid)
            return self._wait_published(session, no_response=True)
        return _response
491706
def send_message(self, *args, **kwargs):
        """"""
        return send_message(*args, **self._merge_overrides(**kwargs)).run()