def check_serializable(cls):
    """Throws an exception if Ray cannot serialize this class efficiently.

    Args:
        cls (type): The class to be serialized.

    Raises:
        Exception: An exception is raised if Ray cannot serialize this class
            efficiently.
    """
    if is_named_tuple(cls):
        # This case works.
        return
    if not hasattr(cls, "__new__"):
        print("The class {} does not have a '__new__' attribute and is "
              "probably an old-stye class. Please make it a new-style class "
              "by inheriting from 'object'.")
        raise RayNotDictionarySerializable("The class {} does not have a "
                                           "'__new__' attribute and is "
                                           "probably an old-style class. We "
                                           "do not support this. Please make "
                                           "it a new-style class by "
                                           "inheriting from 'object'."
                                           .format(cls))
    try:
        obj = cls.__new__(cls)
    except Exception:
        raise RayNotDictionarySerializable("The class {} has overridden "
                                           "'__new__', so Ray may not be able "
                                           "to serialize it efficiently."
                                           .format(cls))
    if not hasattr(obj, "__dict__"):
        raise RayNotDictionarySerializable("Objects of the class {} do not "
                                           "have a '__dict__' attribute, so "
                                           "Ray cannot serialize it "
                                           "efficiently.".format(cls))
    if hasattr(obj, "__slots__"):
        raise RayNotDictionarySerializable("The class {} uses '__slots__', so "
                                           "Ray may not be able to serialize "
                                           "it efficiently.".format(cls))
def check_serializable ( cls ) : if is_named_tuple ( cls ) : return if not hasattr ( cls , "__new__" ) : print ( "The class {} does not have a '__new__' attribute and is " "probably an old-stye class. Please make it a new-style class " "by inheriting from 'object'." ) raise RayNotDictionarySerializable ( "The class {} does not have a " "'__new__' attribute and is " "probably an old-style class. We " "do not support this. Please make " "it a new-style class by " "inheriting from 'object'." . format ( cls ) ) try : obj = cls . __new__ ( cls ) except Exception : raise RayNotDictionarySerializable ( "The class {} has overridden " "'__new__', so Ray may not be able " "to serialize it efficiently." . format ( cls ) ) if not hasattr ( obj , "__dict__" ) : raise RayNotDictionarySerializable ( "Objects of the class {} do not " "have a '__dict__' attribute, so " "Ray cannot serialize it " "efficiently." . format ( cls ) ) if hasattr ( obj , "__slots__" ) : raise RayNotDictionarySerializable ( "The class {} uses '__slots__', so " "Ray may not be able to serialize " "it efficiently." . format ( cls ) )
Throws an exception if Ray cannot serialize this class efficiently.

    Args:
        cls (type): The class to be serialized.

    Raises:
        Exception: An exception is raised if Ray cannot serialize this class
            efficiently.