1 from manifold.operators import LAST_RECORD
4 #------------------------------------------------------------------
6 #------------------------------------------------------------------
9 def __init__(self, deferred=None, router=None, cache_id=None):
10 #def __init__(self, deferred=None, event=None, router=None, cache_id=None):
12 self._deferred = deferred
15 self.event = threading.Event()
21 self.cache_id = cache_id
23 def __call__(self, value):
24 # End of the list of records sent by Gateway
25 if value == LAST_RECORD:
27 # Add query results to cache (expires in 30min)
28 #print "Result added to cached under id", self.cache_id
29 self.router.cache[self.cache_id] = (self.results, time.time() + CACHE_LIFETIME)
32 # Send results back using deferred object
33 self._deferred.callback(self.results)
35 # Not using deferred, trigger the event to return results
39 # Not LAST_RECORD add the value to the results
40 self.results.append(value)
46 def get_results(self):