human
Complete this python program:
def _retry(func):
assistant
#Here is the Python code you requested.

    """Handle query retries.
    """
    def wrapper(obj, *args, **kwargs):
        'Wrap    all    query    functions.'
        update_retries = 5
        while (update_retries > 0):
            try:
                func(obj, *args, **kwargs)
                break
            except (OSError, TypeError, ValueError):
                update_retries -= 1
                if (update_retries == 0):
                    obj.set_state(STATE_OFF)
    return wrapper