def post(self): groupname = self.request.get('group') if groupname == 'ctrp-taskcheck': # Grab the default queue and keep checking for whether or not # all of the tasks have finished. default_queue = Queue() stats = default_queue.fetch_statistics() while stats.tasks > 0: logging.info("task check: waiting for %d tasks to finish" % stats.tasks) time.sleep(5) stats = default_queue.fetch_statistics() self.finishBuilding() else: importer = wowapi.Importer() q = Group.query(Group.name == groupname) groups = q.fetch() # sanity check, tho this shouldn't be possible if len(groups) == 0: logging.info('Builder failed to find group %s' % groupname) return logging.info('Builder task for %s started' % groupname) self.processGroup(groups[0], importer, True) logging.info('Builder task for %s completed' % groupname)
def get(self): queue = Queue() stats = queue.fetch_statistics() template_values = { 'tasks': stats.tasks, 'in_flight': stats.in_flight, } template = JINJA_ENVIRONMENT.get_template('templates/ranker.html') self.response.write(template.render(template_values))
def post(self): # refuse to start the tasks if there are some already running queue = Queue() stats = queue.fetch_statistics() if stats.tasks == 0: print 'nop' taskqueue.add(url='/builder', params={'start': 'A', 'end': 'B'}) taskqueue.add(url='/builder', params={'start': 'C', 'end': 'E'}) taskqueue.add(url='/builder', params={'start': 'F', 'end': 'G'}) taskqueue.add(url='/builder', params={'start': 'H', 'end': 'H'}) taskqueue.add(url='/builder', params={'start': 'I', 'end': 'M'}) taskqueue.add(url='/builder', params={'start': 'N', 'end': 'O'}) taskqueue.add(url='/builder', params={'start': 'P', 'end': 'R'}) taskqueue.add(url='/builder', params={'start': 'S', 'end': 'S'}) taskqueue.add(url='/builder', params={'start': 'T', 'end': 'T'}) taskqueue.add(url='/builder', params={'start': 'U', 'end': 'Z'}) self.redirect('/rank')
def post(self): # refuse to start the tasks if there are some already running queue = Queue() stats = queue.fetch_statistics() if stats.tasks == 0: # queue up all of the groups into individual tasks. the configuration # in queue.yaml only allows 10 tasks to run at once. the builder only # allows 10 URL requests at a time, which should hopefully keep the # Blizzard API queries under control. q = Group.query() groups = q.fetch() for g in groups: taskqueue.add(url='/builder', params={'group': g.name}) checker = Task(url='/builder', params={'group': 'ctrp-taskcheck'}) taskcheck = Queue(name='taskcheck') taskcheck.add(checker) self.redirect('/rank')