(self)
Catch low-level python exceptions, instead re-raising urllib3
        variants, so that low-level exceptions are not leaked in the
        high-level api.

        On exit, release the connection back to the pool.
Catch low-level python exceptions, instead re-raising urllib3
        variants, so that low-level exceptions are not leaked in the
        high-level api.
Catch low - level python exceptions instead re - raising urllib3 variants so that low - level exceptions are not leaked in the high - level api .
def _error_catcher(self):
        """
        Catch low-level python exceptions, instead re-raising urllib3
        variants, so that low-level exceptions are not leaked in the
        high-level api.

        On exit, release the connection back to the pool.
        """
        try:
            try:
                yield

            except SocketTimeout:
                # FIXME: Ideally we'd like to include the url in the ReadTimeoutError but
                # there is yet no clean way to get at it from this context.
                raise ReadTimeoutError(self._pool, None, 'Read timed out.')

            except BaseSSLError as e:
                # FIXME: Is there a better way to differentiate between SSLErrors?
                if 'read operation timed out' not in str(e):  # Defensive:
                    # This shouldn't happen but just in case we're missing an edge
                    # case, let's avoid swallowing SSL errors.
                    raise

                raise ReadTimeoutError(self._pool, None, 'Read timed out.')

            except HTTPException as e:
                # This includes IncompleteRead.
                raise ProtocolError('Connection broken: %r' % e, e)
        except Exception:
            # The response may not be closed but we're not going to use it anymore
            # so close it now to ensure that the connection is released back to the pool.
            if self._original_response and not self._original_response.isclosed():
                self._original_response.close()

            raise
        finally:
            if self._original_response and self._original_response.isclosed():
                self.release_conn()
def _error_catcher ( self ) : try : try : yield except SocketTimeout : # FIXME: Ideally we'd like to include the url in the ReadTimeoutError but # there is yet no clean way to get at it from this context. raise ReadTimeoutError ( self . _pool , None , 'Read timed out.' ) except BaseSSLError as e : # FIXME: Is there a better way to differentiate between SSLErrors? if 'read operation timed out' not in str ( e ) : # Defensive: # This shouldn't happen but just in case we're missing an edge # case, let's avoid swallowing SSL errors. raise raise ReadTimeoutError ( self . _pool , None , 'Read timed out.' ) except HTTPException as e : # This includes IncompleteRead. raise ProtocolError ( 'Connection broken: %r' % e , e ) except Exception : # The response may not be closed but we're not going to use it anymore # so close it now to ensure that the connection is released back to the pool. if self . _original_response and not self . _original_response . isclosed ( ) : self . _original_response . close ( ) raise finally : if self . _original_response and self . _original_response . isclosed ( ) : self . release_conn ( )