Called to abort request on timeout
192757
def abort_request(self, request):
        """"""
        self.timedout = True
        try:
            request.cancel()
        except error.AlreadyCancelled:
            return
717060
function abort() {
            this.aborted = true;
            this.responseText = null;
            this.errorFlag = true;
            this.requestHeaders = {};

            if (this.readyState > IsotropyXMLHttpRequest.UNSENT && this.sendFlag) {
                this._readyStateChange(IsotropyXMLHttpRequest.DONE);
                this.sendFlag = false;
            }

            this.readyState = IsotropyXMLHttpRequest.UNSENT;

            this.dispatchEvent(new HttpRequestEvent("abort", false, false, this));
            if (typeof this.onerror === "function") {
                this.onerror();
            }
        }
726120
def _timeoutRequest(self, msgId):
        
        d, _ = self._requests.pop(msgId, (None, None))
        if not d.called:
            d.errback(ZmqRequestTimeoutError(msgId))
656153
function abort() {
      var event,
          bench = this,
          resetting = calledBy.reset;

      if (bench.running) {
        event = Event('abort');
        bench.emit(event);
        if (!event.cancelled || resetting) {
          // Avoid infinite recursion.
          calledBy.abort = true;
          bench.reset();
          delete calledBy.abort;

          if (support.timeout) {
            clearTimeout(bench._timerId);
            delete bench._timerId;
          }
          if (!resetting) {
            bench.aborted = true;
            bench.running = false;
          }
        }
      }
      return bench;
    }
798250
def _onMethodTimeout(self, serial, d):
        
        del self._pendingCalls[serial]
        d.errback(error.TimeOut('Method call timed out'))
1165508
function abort() {
    this.aborted = true;
    this.responseText = null;
    this.errorFlag = true;
    this.requestHeaders = {};

    this.dispatchEvent(new _Event("abort", false, false, this));

    if (this.readyState > FakeXMLHttpRequest.UNSENT && this.sendFlag) {
      this._readyStateChange(FakeXMLHttpRequest.UNSENT);
      this.sendFlag = false;
    }

    if (typeof this.onerror === "function") {
      this.onerror();
    }
  }
212669
function _abortAllRequests() {
        var req;
        while (this._requests.length > 0) {
            req = this._requests.pop();
            req.abort = true;
            req.xhr.abort();
            // jslint complains, but this is fine. setting to empty func
            // is necessary for IE6
            req.xhr.onreadystatechange = function () {}; // jshint ignore:line
        }
    }
637999
function (req) {
            // increment before assigning to avoid setting request id 0 (which does not work well with abort)
            this.nbRequests++;
            req.id = this.nbRequests;

            var reqMethods = ["GET", "POST", "PUT", "DELETE", "HEAD", "TRACE", "OPTIONS", "CONNECT", "PATCH", "COPY",
                    "PROPFIND", "MKCOL", "PROPPATCH", "MOVE", "LOCK", "UNLOCK", "BIND", "UNBIND", "REBIND"];
            // Assign a request timeout in order of importance:
            // # req.timeout - User specified timeout
            // # req.callback.timeout - Timeout of the callback function (might be set by filters)
            // # this.defaultTimeout - Default IO timeout
            if (req.timeout == null) {
                req.timeout = (req.callback == null || req.callback.timeout == null)
                        ? this.defaultTimeout
                        : req.callback.timeout;
            }

            if (!req.method) {
                req.method = "GET";
            } else {
                req.method = req.method.toUpperCase();
            }

            if (!(require("../utils/Array")).contains(reqMethods, req.method)) {
                return this.$logWarn("The request method %1 is invalid", [req.method]);
            }

            var headers = {};
            // First take the default IO headers
            for (var key in this.headers) {
                if (this.headers.hasOwnProperty(key)) {
                    headers[key] = this.headers[key];
                }
            }
            // Then add POST/PUT-specific headers
            if (req.method === "POST" || req.method === "PUT") {
                for (var key in this.postHeaders) {
                    if (this.postHeaders.hasOwnProperty(key)) {
                        headers[key] = this.postHeaders[key];
                    }
                }
            }
            // Then the headers from the request object
            for (var key in req.headers) {
                if (req.headers.hasOwnProperty(key)) {
                    headers[key] = req.headers[key];
                }
            }

            req.headers = headers;
        }
1295053
synchronized void stop(Integer timeout) {
        final InternalState required = this.requiredState;
        if(required != InternalState.STOPPED) {
            this.requiredState = InternalState.STOPPED;
            ROOT_LOGGER.stoppingServer(serverName);
            // Only send the stop operation if the server is started
            if (internalState == InternalState.SERVER_STARTED) {
                internalSetState(new ServerStopTask(timeout), internalState, InternalState.PROCESS_STOPPING);
            } else {
                transition(false);
            }
        }
    }
1368489
def _timeoutDeferred(deferred, timeout):
    
    delayedCall = reactor.callLater(timeout, deferred.cancel)
    def gotResult(result):
        if delayedCall.active():
            delayedCall.cancel()
        return result
    deferred.addBoth(gotResult)
1346746
public void abort() {
        URL abortURL = this.sessionInfo.getSessionEndpoints().getAbortEndpoint();
        BoxJSONRequest request = new BoxJSONRequest(this.getAPI(), abortURL, HttpMethod.DELETE);
        request.send();
    }
951577
def __invalid_request(self, error):
        
        # TODO: make this modifiable
        error = {
            'error': {
                'message': error
            }
        }
        abort(JsonResponse(status_code=400, data=error))
1022474
function onClientTimeoutPostRequestHandler (ctx, err) {
  if (err) {
    let error = null;
    if (err instanceof SuperError) {
      error = err.rootCause || err.cause || err;
    } else {
      error = err;
    }

    let internalError = new Errors.MostlyError(Constants.EXTENSION_ERROR).causedBy(err);
    ctx.log.error(internalError);

    ctx._response.error = error;
    ctx.emit('clientResponseError', error);
  }

  try {
    ctx._execute(ctx._response.error);
  } catch(err) {
    let error = null;
    if (err instanceof SuperError) {
      error = err.rootCause || err.cause || err;
    } else {
      error = err;
    }

    let internalError = new Errors.FatalError(Constants.FATAL_ERROR, ctx.errorDetails).causedBy(err);
    ctx.log.fatal(internalError);

    ctx.emit('clientResponseError', error);

    // let it crash
    if (ctx._config.crashOnFatal) {
      ctx.fatal();
    }
  }
}
393594
def _timeout(self, timeout, handler, *args, **kw):
        
        t = spawn_thread(target=handler, args=args, kw=kw)
        t.daemon = True
        t.start()
        t.join(timeout)

        if not t.is_alive():
            if t.exc_info:
                return t.exc_info
            return t.result
        else:
            try:
                msg = '[%s] Execution was forcefully terminated'
                raise RuntimeError(msg % t.name)
            except:
                return sys.exc_info()
814918
function onTimeout() {
    const listenerCount = socket.listeners('timeout').length;
    debug('%s(requests: %s, finished: %s) timeout after %sms, listeners %s',
      socket[SOCKET_NAME], socket[SOCKET_REQUEST_COUNT], socket[SOCKET_REQUEST_FINISHED_COUNT],
      getSocketTimeout(socket), listenerCount);
    agent.timeoutSocketCount++;
    const name = agent.getName(options);
    if (agent.freeSockets[name] && agent.freeSockets[name].indexOf(socket) !== -1) {
      // free socket timeout, destroy quietly
      socket.destroy();
      // Remove it from freeSockets list immediately to prevent new requests
      // from being sent through this socket.
      agent.removeSocket(socket, options);
      debug('%s is free, destroy quietly', socket[SOCKET_NAME]);
    } else {
      // if there is no any request socket timeout handler,
      // agent need to handle socket timeout itself.
      //
      // custom request socket timeout handle logic must follow these rules:
      //  1. Destroy socket first
      //  2. Must emit socket 'agentRemove' event tell agent remove socket
      //     from freeSockets list immediately.
      //     Otherise you may be get 'socket hang up' error when reuse
      //     free socket and timeout happen in the same time.
      if (listenerCount === 1) {
        const error = new Error('Socket timeout');
        error.code = 'ERR_SOCKET_TIMEOUT';
        error.timeout = getSocketTimeout(socket);
        // must manually call socket.end() or socket.destroy() to end the connection.
        // https://nodejs.org/dist/latest-v10.x/docs/api/net.html#net_socket_settimeout_timeout_callback
        socket.destroy(error);
        agent.removeSocket(socket, options);
        debug('%s destroy with timeout error', socket[SOCKET_NAME]);
      }
    }
  }
264193
def abort(self):
    
    if self.id == ApiCommand.SYNCHRONOUS_COMMAND_ID:
      return self

    path = self._path() + '/abort'
    resp = self._get_resource_root().post(path)
    return ApiCommand.from_json_dict(resp, self._get_resource_root())
811146
def stop(self, timeout_s=None):
    """"""
    self._live = False
    try:
      self._sock.shutdown(socket.SHUT_RDWR)
      self._sock.close()
    except socket.error:
      pass
    self.join(timeout_s)