def empty(self): with filelock(self.filename,timeout=0.0) as lock: queue = load(self.filename,lock=lock,file_format='pickle') if len(queue.task_list) > 0: return False else: return True
def empty(self): with filelock(self.filename, timeout=0.0) as lock: queue = load(self.filename, lock=lock, file_format='pickle') if len(queue.task_list) > 0: return False else: return True
def check(): with filelock(self.filename, timeout=0.0) as lock: queue = load(self.filename, lock=lock, file_format='pickle') if not queue.max_size is None and queue.unfinished_tasks >= queue.max_size: raise Full queue.unfinished_tasks += 1 queue.task_list.append(task) save(queue, self.filename, lock=lock, file_format='pickle')
def check(): with filelock(self.filename,timeout=0.0) as lock: queue = load(self.filename,lock=lock,file_format='pickle') if not queue.max_size is None and queue.unfinished_tasks >= queue.max_size: raise Full queue.unfinished_tasks += 1 queue.task_list.append(task) save(queue,self.filename,lock=lock,file_format='pickle')
def check(): with filelock(self.filename, timeout=0.0) as lock: queue = load(self.filename, lock=lock, file_format='pickle') queue.unfinished_tasks -= 1 if queue.unfinished_tasks < 0: print 'warning: task_done() called too many times' queue.unfinished_tasks = 0 save(queue, self.filename, lock=lock, file_format='pickle')
def check(): with filelock(self.filename,timeout=0.0) as lock: queue = load(self.filename,lock=lock,file_format='pickle') queue.unfinished_tasks -= 1 if queue.unfinished_tasks < 0: print 'warning: task_done() called too many times' queue.unfinished_tasks = 0 save(queue,self.filename,lock=lock,file_format='pickle')
def check(): with filelock(self.filename,timeout=0.0) as lock: queue = load(self.filename,lock=lock,file_format='pickle') try: task = queue.task_list.pop(0) save(queue,self.filename,lock=lock,file_format='pickle') except IndexError: raise Empty return task
def check(): with filelock(self.filename, timeout=0.0) as lock: queue = load(self.filename, lock=lock, file_format='pickle') try: task = queue.task_list.pop(0) save(queue, self.filename, lock=lock, file_format='pickle') except IndexError: raise Empty return task
def check(): with filelock(self.filename,timeout=0.0) as lock: queue = load(self.filename,lock=lock,file_format='pickle') if len(queue.task_list): task_list = queue.task_list queue.task_list = [] save(queue,self.filename,lock=lock,file_format='pickle') else: raise Empty return task_list
def check(): with filelock(self.filename, timeout=0.0) as lock: queue = load(self.filename, lock=lock, file_format='pickle') if len(queue.task_list): task_list = queue.task_list queue.task_list = [] save(queue, self.filename, lock=lock, file_format='pickle') else: raise Empty return task_list
def check(task_list): with filelock(self.filename, timeout=0.0) as lock: queue = load(self.filename, lock=lock, file_format='pickle') if not queue.max_size is None: n_extend = queue.max_size - queue.unfinished_tasks else: n_extend = len(task_list) this_tasks = [task_list.pop(0) for i in range(n_extend)] queue.unfinished_tasks += n_extend queue.task_list.extend(this_tasks) if len(this_tasks): save(queue, self.filename, lock=lock, file_format='pickle') if len(task_list): raise Full
def check(task_list): with filelock(self.filename,timeout=0.0) as lock: queue = load(self.filename,lock=lock,file_format='pickle') if not queue.max_size is None: n_extend = queue.max_size-queue.unfinished_tasks else: n_extend = len(task_list) this_tasks = [ task_list.pop(0) for i in range(n_extend) ] queue.unfinished_tasks += n_extend queue.task_list.extend(this_tasks) if len(this_tasks): save(queue,self.filename,lock=lock,file_format='pickle') if len(task_list): raise Full
def get(self, key): cache = load(self.filename, file_format='pickle') return cache[key]
def get(self,key): cache = load(self.filename,file_format='pickle') return cache[key]
def set(self,key,value): with filelock(self.filename,self.timeout,self.delay) as lock: cache = load(self.filename,lock=lock,file_format='pickle') cache[key] = value save(cache,self.filename,lock=lock,file_format='pickle')
def check(): with filelock(self.filename, timeout=0.0) as lock: queue = load(self.filename, lock=lock, file_format='pickle') if queue.unfinished_tasks > 0: raise Full
def check(): with filelock(self.filename,timeout=0.0) as lock: queue = load(self.filename,lock=lock,file_format='pickle') if queue.unfinished_tasks > 0: raise Full
def set(self, key, value): with filelock(self.filename, self.timeout, self.delay) as lock: cache = load(self.filename, lock=lock, file_format='pickle') cache[key] = value save(cache, self.filename, lock=lock, file_format='pickle')