'Runs subprocess command to set up remote partner.
Only run the subprocess command once: if using multiple threads, tell
the partner how many paired agents to set up so that they can manage
the multithreading effectively in their environment. (We don\'t run
subprocess.Popen for each thread.)'

def __init__(self, opt, shared=None):

    self.opt = copy.deepcopy(opt)
    self.address = opt['remote_address']
    if (opt.get('remote_host') and (self.address == 'localhost')):
        self.address = '*'
    self.socket_type = (zmq.REP if opt['remote_host'] else zmq.REQ)
    if (shared and ('port' in shared)):
        self.port = shared['port']
    else:
        if ('port' in opt):
            self.port = opt['port']
        else:
            raise RuntimeError((('You    need    to    run    RemoteAgent.' + 'add_cmdline_args(argparser)    before    ') + 'calling    this    class    to    set    up    options.'))
        if opt.get('remote_cmd'):
            self.process = subprocess.Popen('{cmd}    {port}    {numthreads}    {args}'.format(cmd=opt['remote_cmd'], port=opt['port'], numthreads=opt['numthreads'], args=opt.get('remote_args', '')).split())
    self.connect()
    super().__init__(opt, shared)
