'send a Python object as a message using pickle to serialize
Parameters
obj : Python object
The Python object to send.
flags : int
Any valid send flag.
protocol : int
The pickle protocol number to use. The default is pickle.DEFAULT_PROTOCOL
where defined, and pickle.HIGHEST_PROTOCOL elsewhere.'

def send_pyobj(self, obj, flags=0, protocol=DEFAULT_PROTOCOL):

    msg = pickle.dumps(obj, protocol)
    return self.send(msg, flags)
