def __init__(self, conf, singleton=True): # Init the super classes. nfp_launcher.NfpLauncher.__init__(self, conf) NfpService.__init__(self, conf) # For book keeping self._worker_process = {} self._conf = conf self._pipe = None # Queue to stash events. self._stashq = deque() self._manager = nfp_manager.NfpResourceManager(conf, self) self._worker = nfp_worker.NfpWorker(conf) # ID of process handling this controller obj self.PROCESS_TYPE = "distributor"
def start(self): self.worker = nfp_worker.NfpWorker({}, threads=0) self.worker.parent_pipe = self.parent_pipe self.worker.pipe = self.child_pipe self.worker.controller = nfp_controller.NfpController( self.controller._conf) # fork a new controller object self.worker.controller.PROCESS_TYPE = "worker" self.worker.controller._pipe = self.worker.pipe self.worker.controller._event_handlers = ( self.controller._event_handlers) self.worker.event_handlers = self.controller.get_event_handlers() self.parent_pipe.other_end_event_proc_func = ( self.worker._process_event) self.child_pipe.other_end_event_proc_func = ( self.controller._process_event)