Example #1
0
 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
Example #2
0
 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
Example #3
0
 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')
Example #4
0
 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')
Example #5
0
 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')
Example #6
0
 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')
Example #7
0
 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
Example #8
0
 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
Example #9
0
 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
Example #10
0
 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
Example #11
0
        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
Example #12
0
 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
Example #13
0
 def get(self, key):
     cache = load(self.filename, file_format='pickle')
     return cache[key]
Example #14
0
 def get(self,key):
     cache = load(self.filename,file_format='pickle')
     return cache[key]
Example #15
0
 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')        
Example #16
0
 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
Example #17
0
 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
Example #18
0
 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')