def __init__(self, addrport='', id=None, loglevel=logging.INFO, logfile=None, without_httpd=False, numc=2, sup_interval=None, ready_event=None, colored=None, **kwargs): self.id = id or gen_unique_id() if isinstance(addrport, basestring): addr, _, port = addrport.partition(':') addrport = (addr, int(port) if port else 8000) self.addrport = addrport self.connection = celery.broker_connection() self.without_httpd = without_httpd self.logfile = logfile self.loglevel = loglevel self.numc = numc self.ready_event = ready_event self.exit_request = Event() self.colored = colored or term.colored(enabled=False) self.httpd = None gSup = find_symbol(self, self.intsup_cls) if not self.without_httpd: self.httpd = MockSup(instantiate(self, self.httpd_cls, addrport), signals.httpd_ready) self.supervisor = gSup( instantiate(self, self.supervisor_cls, sup_interval), signals.supervisor_ready) self.controllers = [ gSup( instantiate(self, self.controller_cls, id='%s.%s' % (self.id, i), connection=self.connection, branch=self), signals.controller_ready) for i in xrange(1, numc + 1) ] c = [self.supervisor] + self.controllers + [self.httpd] c = self.components = list(filter(None, c)) self._components_ready = dict( zip([z.thread for z in c], [False] * len(c))) for controller in self.controllers: if hasattr(controller.thread, 'presence'): self._components_ready[controller.thread.presence] = False self._components_shutdown = dict(self._components_ready) super(Branch, self).__init__()
def run(self, *actors, **kwargs): if not actors: self.exit_usage('No actor specified') id = kwargs.get('id') loglevel = kwargs.get('loglevel') actors = [instantiate(actor) for actor in list(actors)] connection = Connection(kwargs.get('broker')) agent = Agent(connection, actors=actors, id=kwargs.get('id')) agent.run_from_commandline(loglevel=kwargs.get('loglevel'), logfile=kwargs.get('logfile'))
def __init__(self, addrport='', id=None, loglevel=logging.INFO, logfile=None, without_httpd=False, numc=2, sup_interval=None, ready_event=None, colored=None, **kwargs): self.id = id or gen_unique_id() if isinstance(addrport, basestring): addr, _, port = addrport.partition(':') addrport = (addr, int(port) if port else 8000) self.addrport = addrport self.connection = celery.broker_connection() self.without_httpd = without_httpd self.logfile = logfile self.loglevel = loglevel self.numc = numc self.ready_event = ready_event self.exit_request = Event() self.colored = colored or term.colored(enabled=False) self.httpd = None gSup = find_symbol(self, self.intsup_cls) if not self.without_httpd: self.httpd = MockSup(instantiate(self, self.httpd_cls, addrport), signals.httpd_ready) self.supervisor = gSup(instantiate(self, self.supervisor_cls, sup_interval), signals.supervisor_ready) self.controllers = [gSup(instantiate(self, self.controller_cls, id='%s.%s' % (self.id, i), connection=self.connection, branch=self), signals.controller_ready) for i in xrange(1, numc + 1)] c = [self.supervisor] + self.controllers + [self.httpd] c = self.components = list(filter(None, c)) self._components_ready = dict(zip([z.thread for z in c], [False] * len(c))) for controller in self.controllers: if hasattr(controller.thread, 'presence'): self._components_ready[controller.thread.presence] = False self._components_shutdown = dict(self._components_ready) super(Branch, self).__init__()
def status(self): return instantiate(self, 'cyme.status.Status')
def status(self): return instantiate(self, "cyme.status.Status")