Convert timeout to float.

        Return None if timeout is None, 0 or 0.0. timeout=None disables timeouts in
        Requests.
549576
def _timeout_to_float(self, timeout):
        
        if timeout is not None:
            try:
                timeout_float = float(timeout)
            except ValueError:
                raise ValueError(
                    'timeout_sec must be a valid number or None. timeout="{}"'.format(
                        timeout
                    )
                )
            if timeout_float:
                return timeout_float
82121
def get_float(self, key, optional=False):
        
        return self._get_typed_value(key, float, lambda x: float(x), optional)
18710
def get_delta(value):
    
    if isinstance(value, (int, float)):
        return timedelta(seconds=value)
    elif isinstance(value, timedelta):
        return value
    raise Exception('Invalid delta')
1359101
def _none_value(self):
        
        if self.out_type == int:
            return 0
        elif self.out_type == float:
            return 0.0
        elif self.out_type == bool:
            return False
        elif self.out_type == six.text_type:
            return u''
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
75188
def settimeout(self, timeout):
        '''
        
        '''
        if timeout is None:
            self._block = True
        elif float(timeout) == 0.0:
            self._block = False
        else:
            self._timeout = float(timeout)
            self._block = True
547834
def to_timestamp(self, value):
        
        if isinstance(value, (six.integer_types, float, six.string_types)):
            try:
                return float(value)
            except ValueError:
                value = self.datetime_str_to_datetime(value)

        if isinstance(value, datetime.datetime):
            return self._datetime_to_timestamp(value)

        if value is None:
            try:
                return float(self.default)
            except:
                return 0.0

        raise exceptions.ValidationError(
            "Unable to convert value: '%s' to timestamp" % value,
            code="invalid_timestamp"
        )
1344416
def _convert_to_floats(self, data):
        
        for key, value in data.items():
            data[key] = float(value)

        return data
899421
def settimeout(self, timeout):
        
        if timeout is not None:
            timeout = float(timeout)
        self._timeout = timeout
1038556
def timeout(self, value):
        '''
        
        '''
        if not self.params:
            self.params = dict(timeout=value)
            return self
        self.params['timeout'] = value
        return self
1216981
def wait(self, timeout=None):
        
        # The 'or' part is for Python 2.6
        result = self.__event.wait(timeout)
        # pylint: disable=E0702
        # Pylint seems to miss the "is None" check below
        if self.__exception is None:
            return result
        else:
            raise self.__exception
151391
def set_value(self, value, timeout):
        
        self.value = value
        self.expiration = time.perf_counter() * 1000 + timeout
921678
def _get_timeout(self, timeout):
        
        if timeout is _Default:
            return self.timeout.clone()

        if isinstance(timeout, Timeout):
            return timeout.clone()
        else:
            # User passed us an int/float. This is for backwards compatibility,
            # can be removed later
            return Timeout.from_float(timeout)
1241695
def get_time_rate(self):
        '''
        
        '''
        if isinstance(self.__time_rate, float) is False:
            raise TypeError("The type of __time_rate must be float.")

        if self.__time_rate <= 0.0:
            raise ValueError("The value of __time_rate must be greater than 0.0")

        return self.__time_rate
827034
def safe_float(string, default=None):
    
    value = default
    try:
        value = float(string)
    except TypeError:
        pass
    except ValueError:
        pass
    return value
681951
def do_timeout(self, args):
        

        if not self.current:
            print('There are no resources in use. Use the command "open".')
            return

        args = args.strip()

        if not args:
            try:
                print('Timeout: {}ms'.format(self.current.timeout))
            except Exception as e:
                print(e)
        else:        
            args = args.split(' ')
            try:
                self.current.timeout = float(args[0])
                print('Done')
            except Exception as e:
                print(e)
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