Esempio n. 1
0
 def __init__(
     self,
     host: str,
     timeout: Optional[Union[float, Timeout]] = None,
 ) -> None:
     if isinstance(timeout, float):
         timeout = Timeout.from_float(timeout)
     _ = host
Esempio n. 2
0
    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
Esempio n. 3
0
    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)
Esempio n. 4
0
            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)
Esempio n. 5
0
            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)