~madhuvishy/gtg/bug-676088-fixed

« back to all changes in this revision

Viewing changes to GTG/tools/liblarch/filteredtree.py

  • Committer: Lionel Dricot
  • Date: 2010-09-19 12:35:41 UTC
  • Revision ID: ploum@ploum.net-20100919123541-b5tql9ce9cw2do52
switching to a real lock

Show diffs side-by-side

added added

removed removed

Lines of Context:
113
113
        self.cache_transcount = {}
114
114
        self.cllbcks = {}
115
115
        
116
 
        self.__updating_lock = False
 
116
        self.__updating_lock = threading.Lock()
117
117
        self.__updating_queue = []
118
118
        
119
119
        #filters
192
192
            raise ValueError('cannot update node None')
193
193
        if self.__initialized:
194
194
            self.__updating_queue.append([tid,'update'])
195
 
            if not self.__updating_lock and len(self.__updating_queue) > 0:
196
 
                self.__updating_lock = True
 
195
            if self.__updating_lock.acquire(False) \
 
196
                                        and len(self.__updating_queue) > 0:
197
197
                self.__execution_loop()
198
198
 
199
199
    def external_add_node(self,tid):
201
201
            raise ValueError('cannot add node None')
202
202
        if self.__initialized:
203
203
            self.__updating_queue.append([tid,'add'])
204
 
            if not self.__updating_lock and len(self.__updating_queue) > 0:
205
 
                self.__updating_lock = True
 
204
            if self.__updating_lock.acquire(False)\
 
205
                                        and len(self.__updating_queue) > 0:
206
206
                self.__execution_loop()
207
207
            
208
208
    def external_remove_node(self,tid):
210
210
            raise ValueError('cannot remove node None')
211
211
        if self.__initialized:
212
212
            self.__updating_queue.append([tid,'delete'])
213
 
            if not self.__updating_lock and len(self.__updating_queue) > 0:
214
 
                self.__updating_lock = True
 
213
            if self.__updating_lock.acquire(False)\
 
214
                                        and len(self.__updating_queue) > 0:
215
215
                self.__execution_loop()
216
216
            
217
217
            
239
239
                raise ValueError('%s in not a valid action for the loop') %action
240
240
            prof[1] += time.time() - t
241
241
#            self.print_profile()
242
 
        self.__updating_lock = False
 
242
        self.__updating_lock.release()
243
243
        
244
244
    def print_profile(self):
245
245
        print "*********%s *******" %self