human
Complete this python program:
def check_response(method):
assistant
#Here is the Python program you requested.

    """Decorated functions will run, and if they come back with a 429
    and retry-after header, will wait and try again.
    """
    @functools.wraps(method)
    def wrapped(self, *args, **kwargs):
        response = method(self, *args, **kwargs)
        status = response.status_code
        if (status >= 400):
            if (response.status_code == 429):
                self.handle_429(response, *args, **kwargs)
                return method(self, *args, **kwargs).json()
            msg_args = (response, response.text, response.headers)
            msg = ('Bad    api    response:    %r    %r    %r' % msg_args)
            raise BadAPIResponse(response, msg)
        return response.json()
    return wrapped