示例#1
0
 def __init__(
         self, coroutine, sock_job_for_me_port,
         name=None, connexions=dict(),main_connexion_name=None):
     """
     Parameters
     ----------
     coroutine : Class instance that contains init, run and finish methods
     sock_job_for_me_port: str
         Port number for input socket url
     name: str
         Stage name
     main_connexion_name : str
         Default next step name. Used to send data when destination is not provided
     connexions: dict {'STEP_NANE' : (zmq STEP_NANE port in)}
         Port number for socket for each next steps
     """
     Process.__init__(self)
     Component.__init__(self,parent=None)
     self.name = name
     Connexions.__init__(self,main_connexion_name,connexions)
     self.coroutine = coroutine
     self.sock_job_for_me_url = 'tcp://localhost:' + sock_job_for_me_port
     self.done = False
     self.waiting_since = Value('i',0)
     self._nb_job_done = Value('i',0)
     self._stop = Value('i',0)
     self._running = Value('i',0)
示例#2
0
 def init_connexions(self):
     """
     Initialise zmq sockets.
     Because this class is s Process, This method must be call in the run
      method to be hold by the correct processus.
     """
     self.context = zmq.Context()
     Connexions.init_connexions(self)
     return True
示例#3
0
 def init_connexions(self):
     """
     Initialise zmq sockets.
     Because this class is s Process, This method must be call in the run
      method to be hold by the correct processus.
     """
     Connexions.init_connexions(self)
     context = Context()
     self.sock_for_me = context.socket(REQ)
     self.sock_for_me.connect(self.sock_job_for_me_url)
     # Use a ZMQ Pool to get multichannel message
     self.poll = Poller()
     # Register sockets
     self.poll.register(self.sock_for_me, POLLIN)
     # Send READY to next_router to inform about my capacity to compute new
     # job
     self.sock_for_me.send_pyobj("READY")
     return True
示例#4
0
 def __init__(self, coroutine, name,main_connexion_name,
             connexions=dict()):
     """
     Parameters
     ----------
     coroutine : Class instance
         It contains init, run and finish methods
     name: str
         Producer name
     main_connexion_name : str
         Default next step name. Used to send data when destination is not provided
     connexions: dict {'STEP_NANE' : (zmq STEP_NANE port in)}
         Port number for socket for each next steps
     """
     Process.__init__(self)
     Component.__init__(self,parent=None)
     self.name = name
     Connexions.__init__(self,main_connexion_name,connexions)
     self.coroutine = coroutine
     self.other_requests=dict()
     self._nb_job_done = Value('i',0)
     self._running = Value('i',0)
     self.done = False