Decorator used to make sure, that operation on ZEO object will be retried,
    if there is ``ConnectionStateError`` exception.

def retry_and_reset(fn):
    """
    Decorator used to make sure, that operation on ZEO object will be retried,
    if there is ``ConnectionStateError`` exception.
    """
    @wraps(fn)
    def retry_and_reset_decorator(*args, **kwargs):
        obj = kwargs.get("self", None)

        if not obj:
            obj = args[0]

        try:
            return fn(*args, **kwargs)
        except ConnectionStateError:
            obj._on_close_callback()

        return fn(*args, **kwargs)

    return retry_and_reset_decorator