Example #1
0
def time_aspect2(cutpoint, *args, **kwargs):
    result = yield Proceed(*args, **kwargs)
    if cutpoint.__name__.startswith(
            '_n_'):  # call the actual function with all parameters
        if result == None:
            raise ValueError('None type computed')
        yield Return(result)  # return the result
Example #2
0
def memoize_aspect(f, *args, **kwargs):
    key = f.__name__ + "|" + str(args) + "|" + str(kwargs)
    # print('LOOK AT ME', inspect.getsource(f))
    if(not key in memo):
        memo[key] = yield Proceed(*args, **kwargs)
        yield Return(memo[key])
    else:
        yield Return(memo[key])
Example #3
0
def null_aspect(f, *args, **kwargs):
  result = yield Proceed(*args, **kwargs)

  if f.__name__.startswith('_n_'):
    if result is None:
      raise ValueError('null-safe function returned None!')

  yield Return(result)
Example #4
0
def memoize_aspect(cutpoint, *args, **kwargs):
    if (str(cutpoint.__name__) + str(args)) not in cache:
        cache[str(cutpoint.__name__) + str(args)] = yield Proceed(
            *args, **kwargs)  # call the actual function with all parameters

    return cache[str(cutpoint.__name__) + str(args)]
Example #5
0
def a1(*args, **kwargs):
    g = 100
    print("msg1")
    x = yield Proceed(*args, **kwargs)
    print("msg2")
    yield Return(x + g)
Example #6
0
def a2(*args, **kwargs):
    print("msg1")
    x = yield Proceed(*args, **kwargs)
    yield Return(x)