'Bounce a pickled object through another version of Python.
This will pickle the object, send it to a child process where it will be
unpickled, then repickled and sent back to the parent process.
Args:
python: the name of the Python binary to start.
obj: object to pickle.
proto: pickle protocol number to use.
Returns:
The pickled data received from the child process.'

def send_to_worker(self, python, obj, proto):

    target = __file__
    if (target[(-1)] in ('c', 'o')):
        target = target[:(-1)]
    data = self.module.dumps((proto, obj), proto)
    worker = subprocess.Popen([python, target, 'worker'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    (stdout, stderr) = worker.communicate(data)
    if (worker.returncode != 0):
        raise RuntimeError(stderr)
    return stdout
