Ejemplo n.º 1
0
    def __call__(self, *args, **kwargs):
        scope = rw.scope.get_current_scope()
        rw_tracing = scope.get('rw_trace', None) if scope else None

        re = []
        exceptions = []
        futures = []
        for func in self:
            try:
                result = func(*args, **kwargs)
                if isinstance(result, gen.Future):
                    # we are not waiting for future objects result here
                    # so they evaluate in parallel
                    futures.append((func, result))
                else:
                    re.append(result)
            except Exception:
                exceptions.append((func, traceback.format_exc()))

        # wait for results
        for func, future in futures:
            try:
                if not future.done():
                    yield future
                re.append(future.result())

            except Exception:
                exceptions.append((func, traceback.format_exc()))

        if exceptions:
            raise EventException(exceptions)

        # apply accumolator
        if self.accumulator:
            re = self.accumulator(re)

        raise gen.Return(re)
Ejemplo n.º 2
0
 def inside_scope(self, result, scope):
     assert scope.get('foo') == 1
     self.stop()
Ejemplo n.º 3
0
 def activate(self, scope):
     plugins = scope.get('rw.plugins', {})
     if self not in plugins:
         yield self.activate_event()
         plugins[self] = {}