class_docstr: Base class for the job.
  
  After establishing connection with the remote object, the job will
  create a remote class instance locally and enter an infinite loop
  in a separate process, waiting for commands from the remote object.
class_docstr_tok: ["Base","class","for","the","job",".","After","establishing","connection","with","the","remote","object",",","the","job","will","create","a","remote","class","instance","locally","and","enter","an","infinite","loop","in","a","separate","process",",","waiting","for","commands","from","the","remote","object","."]
docstr: Wait for connection from the remote object.
  
  The remote object will send its class information and initialization
  arguments to the job, these parameters are then used to create a
  local instance in the job process.
  
  Args:
      reply_socket (sockert): main socket to accept commands of remote object.
  
  Returns:
      A local instance of the remote class object.
docstr_tok: ["Wait","for","connection","from","the","remote","object",".","The","remote","object","will","send","its","class","information","and","initialization","arguments","to","the","job",",","these","parameters","are","then","used","to","create","a","local","instance","in","the","job","process",".","Args",":","reply_socket","(","sockert",")",":","main","socket","to","accept","commands","of","remote","object",".","Returns",":","A","local","instance","of","the","remote","class","object","."]
code: def wait_for_connection(self, reply_socket):
      """Wait for connection from the remote object.
  
      The remote object will send its class information and initialization
      arguments to the job, these parameters are then used to create a
      local instance in the job process.
  
      Args:
          reply_socket (sockert): main socket to accept commands of remote object.
  
      Returns:
          A local instance of the remote class object.
      """
  
      message = reply_socket.recv_multipart()
      tag = message[0]
      obj = None
  
      if tag == remote_constants.INIT_OBJECT_TAG:
          try:
              if self.gpu:
                  os.environ["CUDA_VISIBLE_DEVICES"] = self.gpu
              del os.environ["XPARL_igonre_core"]
              importlib.reload(parl)
              cls = load_remote_class(message[1])
              args, kwargs = cloudpickle.loads(message[2])
              with redirect_output_to_file(
                  self.logfile_path, os.devnull
              ):
                  obj = cls(*args, **kwargs)
          except Exception as e:
              traceback_str = str(traceback.format_exc())
              error_str = str(e)
              logger.error("traceback:\n{}".format(traceback_str))
              reply_socket.send_multipart(
                  [
                      remote_constants.EXCEPTION_TAG,
                      to_byte(
                          error_str + "\ntraceback:\n" + traceback_str
                      ),
                  ]
              )
              return None
          reply_socket.send_multipart(
              [
                  remote_constants.NORMAL_TAG,
                  dumps_return(set(obj.__dict__.keys())),
              ]
          )
      else:
          logger.error("Message from job {}".format(message))
          reply_socket.send_multipart(
              [
                  remote_constants.EXCEPTION_TAG,
                  b"[job]Unkonwn tag when tried to receive the class definition",
              ]
          )
          raise NotImplementedError
  
      return obj
  
imports: import os
  import compatible_trick
  import argparse
  import cloudpickle
  import pickle
  import psutil
  import re
  import sys
  import tempfile
  import shutil
  import threading
  import time
  import traceback
  import zmq
  import importlib
  import parl
  from multiprocessing import Process, Pipe
  from parl.utils import to_str, to_byte, get_ip_address, logger
  from parl.remote.communication import loads_argument, loads_return, dumps_argument, dumps_return
  from parl.remote import remote_constants
  from parl.utils.exceptions import SerializeError, DeserializeError
  from parl.remote.message import InitializedJob
  from parl.remote.utils import redirect_output_to_file
  from parl.remote.remote_class_serialization import load_remote_class
  from parl.remote.zmq_utils import create_server_socket, create_client_socket
  from parl.remote.grpc_heartbeat import HeartbeatServerThread, HeartbeatClientThread
label_desc: Use image node_id 6 for calling the Job obj's underlying member method code with example usage: obj.wait_for_connection(reply_socket) and returns: obj, None