Return the timeout value to use, first checking the argument provided to the CLI invocation,
then an environment variable, then the default value.
545757
private static int parseTimeout(
      final Namespace options, final String dest,
      final String envVarName, final int defaultValue) {

    if (options.getInt(dest) != null) {
      return options.getInt(dest);
    }
    if (System.getenv(envVarName) != null) {
      // if this is not an integer then let it blow up
      return Integer.parseInt(System.getenv(envVarName));
    }
    return defaultValue;
  }
403574
def timeout(self, value):
        """"""

        if value == TIMEOUT_SESSION:
            self._config.timeout = None
            self._backend_client.expires = None
        else:
            self._config.timeout = value
            self._calculate_expires()
427496
def runCommand(cmd, timeout=None):
    
    p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
    output = ''

    out, err = p.communicate()
    p.wait(timeout)

    return (out, err)
263290
def read_timeout=(value)
      fail ArgumentError, "must be an integer or float" unless value && (value.is_a?(Integer) || value.is_a?(Float))
      @read_timeout = value
    end
128967
def get(self):
        

        self._cast = type([])
        source_value = os.getenv(self.env_name)

        # set the environment if it is not set
        if source_value is None:
            os.environ[self.env_name] = json.dumps(self.default)
            return self.default

        try:
            val = json.loads(source_value)
        except JSONDecodeError as e:
            click.secho(str(e), err=True, color='red')
            sys.exit(1)
        except ValueError as e:
            click.secho(e.message, err=True, color='red')
            sys.exit(1)

        if self.validator:
            val = self.validator(val)

        return val
242352
def env(var_name, default=False):
    
    try:
        value = os.environ[var_name]
        if str(value).strip().lower() in ['false', 'no', 'off' '0', 'none', 'null']:
            return None
        return value
    except:
        from traceback import format_exc
        msg = format_exc() + '\n' + "Unable to find the %s environment variable.\nUsing the value %s (the default) instead.\n" % (var_name, default)
        warnings.warn(msg)
        return default
1280926
def read_timeout_property value, default
      case value
      when nil   ; read_timeout_property default, default
      when false ; false
      when 0     ; false
      else
        value.is_a?(Numeric) && value > 0 or raise ArgumentError, "value #{value.inspect} should be false, zero, or a positive number."
        value
      end
    end
854653
def check(conn, command, exit=False, timeout=None, **kw):
    
    command = conn.cmd(command)

    stop_on_error = kw.pop('stop_on_error', True)
    timeout = timeout or conn.global_timeout
    if not kw.get('env'):
        # get the remote environment's env so we can explicitly add
        # the path without wiping out everything
        kw = extend_env(conn, kw)

    conn.logger.info('Running command: %s' % ' '.join(admin_command(conn.sudo, command)))
    result = conn.execute(_remote_check, cmd=command, **kw)
    response = None
    try:
        response = result.receive(timeout)
    except Exception as err:
        # the things we need to do here :(
        # because execnet magic, we cannot catch this as
        # `except TimeoutError`
        if err.__class__.__name__ == 'TimeoutError':
            msg = 'No data was received after %s seconds, disconnecting...' % timeout
            conn.logger.warning(msg)
            # there is no stdout, stderr, or exit code but make the exit code
            # an error condition (non-zero) regardless
            return [], [], -1
        else:
            remote_trace = traceback.format_exc()
            remote_error = RemoteError(remote_trace)
            if remote_error.exception_name == 'RuntimeError':
                conn.logger.error(remote_error.exception_line)
            else:
                for tb_line in remote_trace.split('\n'):
                    conn.logger.error(tb_line)
            if stop_on_error:
                raise RuntimeError(
                    'Failed to execute command: %s' % ' '.join(command)
                )
    if exit:
        conn.exit()
    return response
758883
def _get_validated_visibility_timeout(self, timeout=None):
        
        if timeout is not None:
            visibility_timeout = int(timeout)
        else:
            visibility_timeout = int(self.querystring.get("VisibilityTimeout")[0])

        if visibility_timeout > MAXIMUM_VISIBILTY_TIMEOUT:
            raise ValueError

        return visibility_timeout
1003161
private static int initializeTimeout() {
//        Integer tmp = java.security.AccessController.doPrivileged(
//                new GetIntegerAction("com.sun.security.ocsp.timeout"));
        Integer tmp = Integer.getInteger("com.sun.security.ocsp.timeout");
        if (tmp == null || tmp < 0) {
            return DEFAULT_CONNECT_TIMEOUT;
        }
        // Convert to milliseconds, as the system property will be
        // specified in seconds
        return tmp * 1000;
    }
862089
async def _wait_for_cmd(self, cmd, value, timeout=OTGW_DEFAULT_TIMEOUT):
        
        if not self._connected:
            return
        try:
            return await asyncio.wait_for(self._protocol.issue_cmd(cmd, value),
                                          timeout,
                                          loop=self.loop)
        except TimeoutError:
            _LOGGER.error("Timed out waiting for command: %s, value: %s.", cmd,
                          value)
            return
        except (RuntimeError, SyntaxError, ValueError) as exc:
            _LOGGER.error("Command %s with value %s raised exception: %s", cmd,
                          value, exc)
1112376
def timeout(delay, call, *args, **kwargs):
    """"""
    return_value = None

    def target():
        nonlocal return_value
        return_value = call(*args, **kwargs)

    t = Thread(target=target)
    t.start()
    t.join(delay)
    if t.is_alive():
        raise RuntimeError("Operation did not complete within time.")

    return return_value
584101
def getChildTimeoutValue(self):
        """"""
        print '%s call getChildTimeoutValue' % self.port
        childTimeout = self.__sendCommand(WPANCTL_CMD + 'getporp -v Thread:ChildTimeout')[0]
        return int(childTimeout)
58709
def _check_timeout(start_time, timeout):
    '''
    
    '''
    timeout_milisec = timeout * 60000
    if timeout_milisec < (int(round(time.time() * 1000)) - start_time):
        raise salt.exceptions.TimeoutError('Timeout expired.')
1203526
def action_timeout=(t)
      t = t.to_f
      raise ArgumentError.new('Value must be greater than zero or nil') unless t >= 0
      @action_timeout = t
      @threads.each{|thread|thread.action_timeout = t}
      t
    end
1231425
def timeout(self, timeout=None):
        
        if timeout is None:
            return self.__timeout
        if 0 < float(timeout) < 3600:
            self.__timeout = float(timeout)
            return self.__timeout
        else:
            return None
1114952
def get_env_variable(var_name, default=None):
    """"""
    try:
        return os.environ[var_name]
    except KeyError:
        if default is not None:
            return default
        else:
            error_msg = 'The environment variable {} was missing, abort...'\
                        .format(var_name)
            raise EnvironmentError(error_msg)