def sampled(live_config_var):
 def sampled_decorator(fn):
  @functools.wraps(fn)
  def sampled_fn(*a, **kw):
   if (random.random() > g.live_config[live_config_var]):
    return None
   else:
    return fn(*a, **kw)
  return sampled_fn
 return sampled_decorator

def sampled ( live_config_var ) : def sampled_decorator ( fn ) : @ functools . wraps ( fn ) def sampled_fn ( * a , ** kw ) : if ( random . random ( ) > g . live_config [ live_config_var ] ) : return None else : return fn ( * a , ** kw ) return sampled_fn return sampled_decorator
wrap a function that should only actually run occasionally the wrapped function will only actually execute at the rate specified by the live_config sample rate given .