'Send a message with a custom serialization function.
.. versionadded:: 17
Parameters
msg : The message to be sent. Can be any object serializable by `serialize`.
serialize : callable
The serialization function to use.
serialize(msg) should return an iterable of sendable message frames
(e.g. bytes objects), which will be passed to send_multipart.
flags : int, optional
Any valid send flag.
copy : bool, optional
Whether to copy the frames.'

def send_serialized(self, msg, serialize, flags=0, copy=True):

    frames = serialize(msg)
    return self.send_multipart(frames, flags=flags, copy=copy)
