def __init__(self): #Get configuration config = config_lasso() hostname = config.get('lasso', 'hostname') port = config.getint('lasso', 'port') WranglerServer.__init__(self, hostname, port, 'wrangler.lasso') #Setup Code Objects self.decorate_task_object() #Clean Up Database db = Session() tasks = db.query(Task).filter(Task.status==Task.QUEUED).all() for task in tasks: task.status = task.WAITING db.commit() db.close() #Initialize self.heard = dict() self.next_task_lock = thread.allocate_lock() self.queue = PriorityQueue()
def configure(self): self.config = config_lasso()
from random import randint from sqlalchemy import desc import wrangler.generators as generator import wrangler.db.interface as db import wrangler.lassod.interface from wrangler import * from wrangler.db.session import Session from wrangler.queue import * from wrangler.config import config_lasso from wrangler.network import WranglerServer from wrangler.cattled.client import CattleClient config = config_lasso() log = logging.getLogger('wrangler.lasso') class CattleRuntime(object): """Holds runtime information about cattle.""" def __init__(self, hostname): self.hostname = hostname self.started = datetime.datetime.now() self.tasks = {} self.pulse() def pulse(self): self.last_pulse = datetime.datetime.now() log.debug('Received pulse from %s.' % self.hostname) return self.last_pulse