Helper for multiprocessing.

def __RemoteExecuteHelper(args):
  """ Helper for multiprocessing. """
  cmd, hostname, ssh_key = args
  #Random.atfork()  # needed to fix bug in old python 2.6 interpreters
  private_key = paramiko.RSAKey.from_private_key(StringIO.StringIO(ssh_key))
  client = paramiko.SSHClient()
  client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  while True:
      try:
          client.connect(hostname, username='ubuntu', pkey=private_key, 
                         allow_agent=False, look_for_keys=False)
          break
      except socket.error as e:
          print '.'
          time.sleep(5)
      except paramiko.AuthenticationException as e:
          print e
          time.sleep(5)
  channel = client.get_transport().open_session()
  channel.exec_command(cmd)
  exit_code = channel.recv_exit_status()
  output = channel.recv(1000000)
  client.close()
  return exit_code, output