def dask_dumps(x, context=None): """Serialise object using the class-based registry""" type_name = typename(type(x)) try: dumps = dask_serialize.dispatch(type(x)) except TypeError: raise NotImplementedError(type_name) if has_keyword(dumps, "context"): header, frames = dumps(x, context=context) else: header, frames = dumps(x) header["type"] = type_name header["type-serialized"] = pickle.dumps(type(x)) header["serializer"] = "dask" return header, frames
def register_serialization_family(name, dumps, loads): families[name] = (dumps, loads, dumps and has_keyword(dumps, "context"))