Example #1
0
File: base.py Project: SMAC/corelib
 def start(self, *args, **kwargs):
     log.debug("Starting server for compound task '{0}'".format(self.id))
     address = amqp.models.Address(routing_key='*')
     yield amqp.build_server(address, TaskListener, self, self.queues)
     
     address = amqp.models.Address(routing_key='tasks.{0}.updates'.format(self.id))
     self._task_client = yield amqp.build_client(address, TaskListener, distribution='tasks')
     
     r = yield defer.maybeDeferred(self.run, *args, **kwargs)
     self.notify()
     defer.returnValue(r)
Example #2
0
File: base.py Project: SMAC/corelib
 def start(self, *args, **kwargs):
     assert self.status is types.TaskStatus.WAITING, "Task already started"
     
     address = amqp.models.Address(routing_key=self.id)
     yield amqp.build_server(address, TaskServer, self, self.queues)
     
     address = amqp.models.Address(routing_key='tasks.{0}.updates'.format(self.id))
     self._task_client = yield amqp.build_client(address, TaskListener, distribution='tasks')
     
     self._started = time.time()
     r = yield defer.maybeDeferred(self.run, *args, **kwargs)
     self.status = types.TaskStatus.RUNNING
     defer.returnValue(r)
Example #3
0
File: base.py Project: SMAC/corelib
 def add(self, task):
     assert task.parent == self.id
     
     yield self.add_lock.acquire()
     
     try:
         if task.id not in self.children:
             log.debug("New child task received ({0})".format(task.id))
             address = amqp.models.Address(routing_key='tasks.{0}.commands'.format(task.id))
             self.clients[task.id] = yield amqp.build_client(address, TaskServer, distribution='tasks')
         
         self.children[task.id] = ITask(task)
         self.tasks = self.children.values()
     finally:
         self.add_lock.release()
Example #4
0
 def build_client(self):
     key = "sessions.{0}.commands".format(self.sessid)
     address = amqp.models.Address(routing_key=key)
     return amqp.build_client(address, api.session.SessionListener,
             distribution='sessions')
Example #5
0
 def add(self, task_id):
     address = amqp.models.Address(routing_key='tasks.{0}.commands'.format(task_id))
     client = yield amqp.build_client(address, TaskServer, distribution='tasks')
     task = yield client.info()
     self.update(task)