def _wrap_functions(self, client):
def wrap(fn):<EOL><INDENT>def wrapper(*args, **kwargs):<EOL><INDENT>"""<STR_LIT>"""<EOL>try:<EOL><INDENT>return fn(*args, **kwargs)<EOL><DEDENT>except (ConnectionError, TimeoutError):  <EOL><INDENT>self._penalize_client(client)<EOL>raise<EOL><DEDENT><DEDENT>return functools.update_wrapper(wrapper, fn)<EOL><DEDENT>for name in dir(client):<EOL><INDENT>if name.startswith("<STR_LIT:_>"):<EOL><INDENT>continue<EOL><DEDENT>if name in ("<STR_LIT>", "<STR_LIT>", "<STR_LIT>"):<EOL><INDENT>continue<EOL><DEDENT>obj = getattr(client, name)<EOL>if not callable(obj):<EOL><INDENT>continue<EOL><DEDENT>log.debug("<STR_LIT>", name)<EOL>setattr(client, name, wrap(obj))<EOL><DEDENT>
Wrap public functions to catch ConnectionError.

        When an error happens, it puts the client in the penalty box
        so that it won't be retried again for a little while.