def fetch(self, lst): now_time = int(time.time()) for source_id in lst: if source_id in self.running_map: sec_ago = now_time - self.running_map[source_id] print('%s已经于%d秒前运行,尚未结束' % (source_id, sec_ago)) continue elif source_id in self.queue_set: print('%s已经在队列中,请等待' % source_id) continue # run if has slots if len(self.running_map) < self.gcfg.task_pipes: self.running_map[source_id] = now_time item = c_running_unit(source_id, now_time + self.gcfg.task_timeout) self.running_sorted_list.append(item) worker_manage.worker_starter(self.gcfg.runcfg, source_id) # no slots, add to deque else: self.queue_set.add(source_id) self.queue_deque.append(source_id)
def fresh_job(self): now_time = int(time.time()) while self.queue_set and len(self.running_map) < self.gcfg.task_pipes: # remove from queue source_id = self.queue_deque.popleft() self.queue_set.remove(source_id) # add to running self.running_map[source_id] = now_time item = c_running_unit(source_id, now_time + self.gcfg.task_timeout) self.running_sorted_list.append(item) # start thread worker_manage.worker_starter(self.gcfg.runcfg, source_id)
def fresh_job(self): now_time = int(time.time()) while self.queue_set and \ len(self.running_map) < self.gcfg.task_pipes: # remove from queue source_id = self.queue_deque.popleft() self.queue_set.remove(source_id) # add to running self.running_map[source_id] = now_time item = c_running_unit(source_id, now_time + self.gcfg.task_timeout) self.running_sorted_list.append(item) # start thread worker_manage.worker_starter(self.gcfg.runcfg, source_id)
def fetch(self, lst): now_time = int(time.time()) for source_id in lst: if source_id in self.running_map: sec_ago = now_time - self.running_map[source_id] print("%s已经于%d秒前运行,尚未结束" % (source_id, sec_ago)) continue elif source_id in self.queue_set: print("%s已经在队列中,请等待" % source_id) continue # run if has slots if len(self.running_map) < self.gcfg.task_pipes: self.running_map[source_id] = now_time item = c_running_unit(source_id, now_time + self.gcfg.task_timeout) self.running_sorted_list.append(item) worker_manage.worker_starter(self.gcfg.runcfg, source_id) # no slots, add to deque else: self.queue_set.add(source_id) self.queue_deque.append(source_id)