def __init__( self, host: str, timeout: Optional[Union[float, Timeout]] = None, ) -> None: if isinstance(timeout, float): timeout = Timeout.from_float(timeout) _ = host
def __init__( self, host: str, timeout: Optional[Union[float, Timeout]] = None, ) -> None: if isinstance(timeout, float): timeout = Timeout.from_float(timeout) super().__init__("localhost", timeout=timeout, retries=10) self.host = host
def __init__(self, *args, **kwargs): # pull out and transform Timeout parameters from kwargs; # values for read and connect timeouts are set by default # and may be disabled by passing 'None' timeout_kwargs = {} if 'read_timeout' in kwargs: read_timeout = kwargs.pop('read_timeout') if read_timeout is not None: timeout_kwargs['read'] = read_timeout else: timeout_kwargs['read'] = 180.0 if 'connect_timeout' in kwargs: connect_timeout = kwargs.pop('connect_timeout') if connect_timeout is not None: timeout_kwargs['connect'] = connect_timeout else: timeout_kwargs['connect'] = 2.0 self.timeout = Timeout(**timeout_kwargs) super(BoxHTTPAdapter, self).__init__(*args, **kwargs)
def urlopen(*args, **kwargs): timeout = kwargs.pop("timeout", None) if isinstance(timeout, Timeout): timeout = Timeout.from_float(timeout.connect_timeout) return orig_urlopen(*args, timeout=timeout, **kwargs)