diff options
author | Frederic Leger | 2014-03-13 16:40:17 +0000 |
---|---|---|
committer | Frederic Leger | 2014-03-13 16:40:17 +0000 |
commit | 6f2ca0fd5d13419c2f6a7bd5845079d7ead2a2b9 (patch) | |
tree | 6e5dd785e09e553e6db9c15aa4e2a660c994bc9f /python/src/tcf/util/cache.py | |
parent | 31fce654cf845e51ccb3b977871c069a9d6923e3 (diff) | |
download | org.eclipse.tcf-6f2ca0fd5d13419c2f6a7bd5845079d7ead2a2b9.tar.gz org.eclipse.tcf-6f2ca0fd5d13419c2f6a7bd5845079d7ead2a2b9.tar.xz org.eclipse.tcf-6f2ca0fd5d13419c2f6a7bd5845079d7ead2a2b9.zip |
Python - Cache utility update.
Prevent waiting list manipulation errors.
Diffstat (limited to 'python/src/tcf/util/cache.py')
-rw-r--r-- | python/src/tcf/util/cache.py | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/python/src/tcf/util/cache.py b/python/src/tcf/util/cache.py index f64344ba2..3998c16fc 100644 --- a/python/src/tcf/util/cache.py +++ b/python/src/tcf/util/cache.py @@ -11,6 +11,7 @@ import cStringIO from .. import protocol, channel +from .task import Task class DataCache(object): @@ -121,10 +122,16 @@ class DataCache(object): if self.__waiting_list: arr = self.__waiting_list self.__waiting_list = None - for r in arr: - if isinstance(r, DataCache) and r._DataCache__posted: - continue - r() + for r in tuple(arr): + if isinstance(r, DataCache): + r.post() + elif isinstance(r, Task) and not r.isDone(): + r.run() + else: + r() + + arr.remove(r) + if self.__waiting_list is None: self.__waiting_list = arr @@ -154,10 +161,7 @@ class DataCache(object): """ if not self.__waiting_list: return False - for r in self.__waiting_list: - if r is cb: - return True - return False + return cb in self.__waiting_list def __validate(self): """ @@ -193,8 +197,7 @@ class DataCache(object): @return True if the cache is already valid """ if not self.__validate(): - if cb: - self.wait(cb) + self.wait(cb) return False return True |