before/after call will encapsulate callable object
160510
def wrap_object(func, before, after):
    '''
    
    '''
    def _wrapper(*args, **kwargs):
        before()
        try:
            return func(*args, **kwargs)
        except Exception as e:
            raise e
        finally:
            after()
    return _wrapper
356989
function beforeCommit(object, callback) {
  var self = this;
  async.waterfall([
    this.triggerTransformEvent.bind(this, 'prepare', object),
    this.triggerProgressionEvent.bind(this, 'validate'),
    this.triggerEvent.bind(this, 'beforeSave')
  ], function(err, object) {
    if (err) return callback(err);

    // run beforeCommit on all composed objects as well.
    transformComps.call(self, object, object, function(comp, object, i, cb) {
      if (comp.transient) return cb();
      beforeCommit.call(comp.model, object, cb);
    }, callback);
  });
}
861612
def write_render_callable(self, node, name, args, buffered, filtered,
            cached):
        """"""

        if self.in_def:
            decorator = node.decorator
            if decorator:
                self.printer.writeline(
                                "@runtime._decorate_toplevel(%s)" % decorator)

        self.printer.start_source(node.lineno)
        self.printer.writelines(
            "def %s(%s):" % (name, ','.join(args)),
                # push new frame, assign current frame to __M_caller
                "__M_caller = context.caller_stack._push_frame()",
                "try:"
        )
        if buffered or filtered or cached:
            self.printer.writeline("context._push_buffer()")

        self.identifier_stack.append(
                                self.compiler.identifiers.branch(self.node))
        if (not self.in_def or self.node.is_block) and '**pageargs' in args:
            self.identifier_stack[-1].argument_declared.add('pageargs')

        if not self.in_def and (
                                len(self.identifiers.locally_assigned) > 0 or
                                len(self.identifiers.argument_declared) > 0
                                ):
            self.printer.writeline("__M_locals = __M_dict_builtin(%s)" %
                                    ','.join([
                                            "%s=%s" % (x, x) for x in
                                            self.identifiers.argument_declared
                                            ]))

        self.write_variable_declares(self.identifiers, toplevel=True)

        for n in self.node.nodes:
            n.accept_visitor(self)

        self.write_def_finish(self.node, buffered, filtered, cached)
        self.printer.writeline(None)
        self.printer.write_blanks(2)
        if cached:
            self.write_cache_decorator(
                                node, name,
                                args, buffered,
                                self.identifiers, toplevel=True)
5678
def make_wrapper(self, callable_):
        """"""
        assert callable(callable_)
        def wrapper(*args, **kw):
            return self.call_and_report_errors(callable_, *args, **kw)
        return wrapper
31882
def after(self, func):
        
        ns = self.Namespace()
        ns.times = self.obj

        if ns.times <= 0:
            return func()

        def work_after(*args):
            if ns.times <= 1:
                return func(*args)
            ns.times -= 1

        return self._wrap(work_after)
605067
private function initialize()
    {
        if ($this->callable !== null) {
            // $func will be $adapter->fetchObjectFromCache();
            $func                      = $this->callable;
            $result                    = $func();
            $this->hasValue            = $result[0];
            $this->value               = $result[1];
            $this->prevTags            = isset($result[2]) ? $result[2] : [];
            $this->expirationTimestamp = null;

            if (isset($result[3]) && is_int($result[3])) {
                $this->expirationTimestamp = $result[3];
            }

            $this->callable = null;
        }
    }
328356
function after(obj, func) {
  if (isPromise(obj)) {
    return obj.then(func);
  } else {
    return func(obj);
  }
}
751991
private function after(callable $after): void
    {
        if ($after instanceof Closure) {
            $this->options["after"] = $after->bindTo($this);
        } else {
            $this->options["after"] = $after;
        }
    }
1217593
def bind(self, __fun, *args, **kwargs):
    

    with self._lock:
      if self._running or self._completed or self._cancelled:
        raise RuntimeError('Future object can not be reused')
      if self._worker:
        raise RuntimeError('Future object is already bound')
      self._worker = functools.partial(__fun, *args, **kwargs)
    return self
476607
function executeCallback(cb, arg) {
    var r = cb(arg)
    if(r !== undefined && !isLikeAFuture(r) )
        throw Error("Value returned from then or catch ("+r+") is *not* a Future. Callback: "+cb.toString())

    return r
}
368595
def _start_callables(self, row, callables):
        
        id_vals = {c: row[c] for c in self.ids}

        def callback(tab, cols, result):
            if isinstance(result, Mapping):
                pass
            elif isinstance(result, tuple):
                result = dict(zip(cols, result))
            elif len(cols) == 1:
                # Don't bother raising an exception if cols != 1
                # because it would be lost in the thread.
                result = {cols[0]: result}
            result.update(id_vals)
            tab._write(result)

        if self._pool is None:
            self._pool = Pool()
        if self._lock is None:
            self._lock = multiprocessing.Lock()

        for cols, fn in callables:
            cb_func = partial(callback, self, cols)

            gen = None
            if inspect.isgeneratorfunction(fn):
                gen = fn()
            elif inspect.isgenerator(fn):
                gen = fn

            if gen:
                def callback_for_each():
                    for i in gen:
                        cb_func(i)
                self._pool.apply_async(callback_for_each)
            else:
                self._pool.apply_async(fn, callback=cb_func)
924561
def create_callable(hook)
      callback = proc do |trans_event, *data|
        machine.instance_exec(trans_event, *data, &hook)
      end
      Callable.new(callback)
    end
138574
def after(self, time, function, args = []):
        """"""
        callback_id = self.tk.after(time, self._call_wrapper, time, function, *args)
        self._callback[function] = [callback_id, False]
991209
private void visitFrameAfterMethodReturnCallback() {
        if (!visitFramesAfterCallbacks)
            return;

        Type returnType = getReturnTypeForTrace();
        if (!Type.VOID_TYPE.equals(getReturnTypeForTrace()) && !isConstructor()) {
            Object typeDescriptor = null;
            switch (returnType.getSort()) {
                case Type.BOOLEAN:
                case Type.BYTE:
                case Type.CHAR:
                case Type.INT:
                case Type.SHORT:
                    typeDescriptor = INTEGER;
                    break;
                case Type.DOUBLE:
                    typeDescriptor = DOUBLE;
                    break;
                case Type.FLOAT:
                    typeDescriptor = FLOAT;
                    break;
                case Type.LONG:
                    typeDescriptor = LONG;
                    break;
                default:
                    typeDescriptor = returnType.getInternalName();
                    break;
            }
            visitFrame(F_SAME1, 0, null, 1, new Object[] { typeDescriptor });
        } else {
            visitFrame(F_SAME, 0, null, 0, null);
        }
    }
465725
private function before(callable $before): void
    {
        if ($before instanceof Closure) {
            $this->options["before"] = $before->bindTo($this);
        } else {
            $this->options["before"] = $before;
        }
    }
358982
def decode_call(self, call):
        
        # Callable name is None when callable is part of exclude list
        if call is None:
            return None
        itokens = call.split(self._callables_separator)
        odict = {}
        for key, value in self._clut.items():
            if value in itokens:
                odict[itokens[itokens.index(value)]] = key
        return self._callables_separator.join([odict[itoken] for itoken in itokens])
180037
function wrapANodeMethods (obj) {
  var newObj = {};
  var ANodeMethods = [
    'attachedCallback',
    'attributeChangedCallback',
    'createdCallback',
    'detachedCallback'
  ];
  wrapMethods(newObj, ANodeMethods, obj, ANode.prototype);
  copyProperties(obj, newObj);
  return newObj;
}