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 __init__(self, filename, max_size=None, delay=0.5, new=False): self.filename = os.path.abspath(filename) self.delay = delay # start the queue data file if needed if not os.path.exists(self.filename) or new: queue = QueueData() queue.max_size = max_size if os.path.exists(self.filename): lock = filelock(self.filename, MASTER_TIMEOUT, self.delay) else: lock = None save(queue, self.filename, file_format='pickle', lock=lock)
def __init__( self, filename, max_size=None, delay=0.5, new=False): self.filename = os.path.abspath(filename) self.delay = delay # start the queue data file if needed if not os.path.exists(self.filename) or new: queue = QueueData() queue.max_size = max_size if os.path.exists(self.filename): lock = filelock(self.filename,MASTER_TIMEOUT,self.delay) else: lock = None save(queue,self.filename,file_format='pickle',lock=lock)
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 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 close(self): with filelock(self.filename,timeout=MASTER_TIMEOUT) as lock: os.remove(self.filename)
def close(self): with filelock(self.filename, timeout=MASTER_TIMEOUT) as lock: os.remove(self.filename)
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')
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