Send any write requests which were queued whilst waiting for handshaking to complete.
541087
protected synchronized void flushPendingWriteRequests() throws Exception {
        LOGGER.debug(" flushPendingWriteRequests()");

        if (writeRequestQueue == null) {
            return;
        }

        Event scheduledWrite;
        while ((scheduledWrite = writeRequestQueue.poll()) != null) {
            LOGGER.debug(" Flushing buffered write request: {}",
                    scheduledWrite.data);

            getProxyFilter().filterWrite(scheduledWrite.nextFilter,
                    getSession(), (WriteRequest) scheduledWrite.data);
        }

        // Free queue
        writeRequestQueue = null;
    }
934488
def send_async_request(params)
      data = send_request(params)

      params = {
        'command' => 'queryAsyncJobResult',
        'jobid' => data['jobid']
      }

      max_tries.times do
        data = send_request(params)
        print "." if @verbose

        case data['jobstatus']
        when 1
          return data['jobresult']
        when 2
          raise JobError, "Request failed (#{data['jobresultcode']}): #{data['jobresult']['errortext']}."
        end

        STDOUT.flush if @verbose
        sleep @async_poll_interval
      end

      raise TimeoutError, "Asynchronous request timed out."
    end
19627
public void sendAllMessage() {
    if (!isConnected()) {
      return;
    }

    LOG.info("Flushing all pending data in MetricsManagerClient");
    // Collect all tuples in queue
    for (Communicator<Metrics.MetricPublisherPublishMessage> c : outMetricsQueues) {
      int size = c.size();
      for (int i = 0; i < size; i++) {
        Metrics.MetricPublisherPublishMessage m = c.poll();
        sendMessage(m);
      }
    }
  }
387612
protected void sendRequests() {
        if ( ! requestUnderway ) {
            requestUnderway = true;
            delayed( new Runnable() {
                @Override
                public void run() {
                    synchronized (requests) {
                        Object req[];
                        if ( openFutureRequests.get() > 0 && requests.size() == 0 ) {
                            req = new Object[] { "SP", lastSeenSeq };
                        } else {
                            req = new Object[requests.size() + 1];
                            for (int i = 0; i < requests.size(); i++) {
                                req[i] = requests.get(i);
                            }
                            req[req.length - 1] = lastSeenSeq;
                            requests.clear();
                        }

                        sendCallArray(req).then(new Callback<Integer>() {
                            @Override
                            public void receive(Integer result, Object error) {
                                synchronized (requests ) {
                                    requestUnderway = false;
                                    if ( requests.size() > 0 || (result != null && result > 0 && openFutureRequests.get() > 0 ) ) {
                                        myExec.execute(new Runnable() {
                                            @Override
                                            public void run() {
                                            sendRequests();
                                            }
                                        });
                                    }
                                }
                            }
                        });
                    }
                }
            }, 1);
        }
    }
255281
protected void onSuccess(AsyncRequest<D, RQ> asyncRequest, ResponseStatus status) {
    final WriteResponse response = WriteResponse.EMPTY;
    for (final AsyncRequest.Thunk thunk: asyncRequest.getThunks()) {
      WriteCallback callback = (WriteCallback) thunk.callback;
      callback.onSuccess(new WriteResponse() {
        @Override
        public Object getRawResponse() {
          return response.getRawResponse();
        }

        @Override
        public String getStringResponse() {
          return response.getStringResponse();
        }

        @Override
        public long bytesWritten() {
          return thunk.sizeInBytes;
        }
      });
    }
  }
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
579726
def send(self, msg):
        """"""
        if self._req_ctx is not None:
            self._send(msg)
        else:
            self._send_queue.put(msg)
            self._event.set()
1354204
public HandshakerResp send(HandshakerReq req) throws InterruptedException, IOException {
    maybeThrowIoException();
    if (!responseQueue.isEmpty()) {
      throw new IOException("Received an unexpected response.");
    }
    writer.onNext(req);
    Optional<HandshakerResp> result = responseQueue.take();
    if (!result.isPresent()) {
      maybeThrowIoException();
    }
    return result.get();
  }
327064
def expect_handshake(self, headers):
        
        init_req = yield self.reader.get()
        if init_req.message_type != Types.INIT_REQ:
            raise errors.UnexpectedError(
                "You need to shake my hand first. Got %s" % repr(init_req)
            )
        self._extract_handshake_headers(init_req)
        self._handshake_performed = True

        self.writer.put(
            messages.InitResponseMessage(
                PROTOCOL_VERSION, headers, init_req.id),
        )

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

        raise tornado.gen.Return(init_req)
1297860
async def send(self, data):
        
        self.writer.write(data)
        await self.writer.drain()
1049371
private void sendQueuedInvocations() {
        while (true) {
            MethodInvocation<?> currentRPC = queuedRpcList.poll();
            if (currentRPC == null) {
                return;
            }

            try {
                connector.executeAsyncMethod(currentRPC.getProxy(),
                                             currentRPC.getMethod(),
                                             currentRPC.getArgs(),
                                             currentRPC.getFuture());
            } catch (JoynrRuntimeException e) {
                currentRPC.getFuture().onFailure(e);
            } catch (Exception e) {
                currentRPC.getFuture().onFailure(new JoynrRuntimeException(e));
            }

        }

    }
962658
def make_request(self, handle, value, timeout=DEFAULT_TIMEOUT, with_response=True):
        """"""
        try:
            with self:
                _LOGGER.debug("Writing %s to %s with with_response=%s", codecs.encode(value, 'hex'), handle, with_response)
                self._conn.writeCharacteristic(handle, value, withResponse=with_response)
                if timeout:
                    _LOGGER.debug("Waiting for notifications for %s", timeout)
                    self._conn.waitForNotifications(timeout)
        except btle.BTLEException as ex:
            _LOGGER.debug("Got exception from bluepy while making a request: %s", ex)
            raise
1083028
async def send_script(self, conn_id, data):
        

        progress_callback = functools.partial(_on_progress, self, 'script', conn_id)

        resp = await self._execute(self._adapter.send_script_sync, conn_id, data, progress_callback)
        _raise_error(conn_id, 'send_rpc', resp)
629677
async def _flush(self, request: 'Request', stacks: List[Stack]):
        

        for stack in stacks:
            await self.platform.send(request, stack)
221074
public void send(Packet packet) {
        if (log.isTraceEnabled()) {
            log.trace("send packet: {}", packet);
        }
        // no handshake flag, queue the packet
        if (session.containsAttribute(Constants.HANDSHAKE_COMPLETE)) {
            try {
                // clear any queued items first
                queue.forEach(entry -> {
                    session.write(entry);
                    queue.remove(entry);
                });
            } catch (Exception e) {
                log.warn("Exception draining queued packets on session: {}", session.getId(), e);
            }
            // process the incoming packet
            session.write(packet);
        } else {
            if (handshakeWriteFuture != null) {
                log.warn("Handshake is not complete yet on session: {} written? {}", session.getId(), handshakeWriteFuture.isWritten(), handshakeWriteFuture.getException());
            } else {
                log.warn("Handshake is not complete yet on session: {}", session.getId());
            }
            // not queuing pings
            MessageType type = packet.getType();
            if (type != MessageType.PING && type != MessageType.PONG) {
                log.info("Placing {} message in session: {} queue", type, session.getId());
                queue.offer(packet);
            }
        }
    }
1051158
def send_complete(self):
        
        self.active = True

        if self.should_finish():
            self._detach()

            # Avoid race condition when waiting for write callback and session getting closed in between
            if not self._finished:
                self.safe_finish()
        else:
            if self.session:
                self.session.flush()
296054
def enable_writes(self):
        """"""
        self.write_buffer = []
        self.flush_lock = threading.RLock()
        self.flush_thread = FlushThread(self.max_batch_time,
                                        self._flush_writes)