Register a hook to be called after a command is completed, whether it completes successfully or not.
556650
def register_cmdfinalization_hook(self, func: Callable[[plugin.CommandFinalizationData],
                                                           plugin.CommandFinalizationData]) -> None:
        """"""
        self._validate_cmdfinalization_callable(func)
        self._cmdfinalization_hooks.append(func)
622673
function(){
                if (executionChainDone){
                    console.log('execution done !!!')
                    return;
                }
                if (i >= _middleware.length){

                    fn(request,response);
                }
                else{
                    mf = _middleware[i];
                    i++;
                    mf(request,response,next);
                }
            }
1121899
public void registerCommandHandler(String key, CommandHandler handler) {
        if (TraceComponent.isAnyTracingEnabled()
            && tc.isEntryEnabled())
            SibTr.entry(tc, "registerCommandHandler", new Object[] { key,
                                                                    handler });

        // Add handler to table
        // Note that if there was already a handler with this key it's table
        // entry will
        // be overwritten
        synchronized (_registeredHandlers) {
            _registeredHandlers.put(key, handler);
        }

        if (TraceComponent.isAnyTracingEnabled()
            && tc.isEntryEnabled())
            SibTr.exit(tc, "registerCommandHandler");
    }
777979
def register_preloop_hook(self, func: Callable[[None], None]) -> None:
        """"""
        self._validate_prepostloop_callable(func)
        self._preloop_hooks.append(func)
549305
def _RunSingleHook(self, hook_cls, executed_set, required=None):
    """"""
    # If we already ran do nothing.
    if hook_cls in executed_set:
      return

    # Ensure all the pre execution hooks are run.
    for pre_hook in hook_cls.pre:
      self._RunSingleHook(pre_hook, executed_set, required=hook_cls.__name__)

    # Now run this hook.
    cls_instance = hook_cls()
    if required:
      logging.debug("Initializing %s, required by %s", hook_cls.__name__,
                    required)
    else:
      logging.debug("Initializing %s", hook_cls.__name__)

    # Always call the Run hook.
    cls_instance.Run()
    executed_set.add(hook_cls)

    # Only call the RunOnce() hook if not already called.
    if hook_cls not in self.already_run_once:
      cls_instance.RunOnce()
      self.already_run_once.add(hook_cls)
1346223
public function register($hook, $callback, $priority = 0) {
		if (!isset($this->hooks[$hook])) {
			$this->hooks[$hook] = array();
		}
		if (!isset($this->hooks[$hook][$priority])) {
			$this->hooks[$hook][$priority] = array();
		}

		$this->hooks[$hook][$priority][] = $callback;
	}
318992
def register_hooks(func, hooks, obj):
    
    for name, args, kwargs in hooks:
        hook = getattr(obj, name)
        force_call = kwargs.pop("_force_call", False)
        if force_call or len(args) > 0 or len(kwargs) > 0:
            hook = hook(*args, **kwargs)
        hook(func)
436211
def post_command_event(target, msg_cls, **kwargs):
    

    msg = msg_cls(id=-1, **kwargs)
    wx.PostEvent(target, msg)
1168760
def on_hook(self, hook):
        # type: (Hook) -> None
        """"""
        try:
            func, args_gen = self.hooked[type(hook)]
        except (KeyError, TypeError):
            return
        else:
            hook(func, args_gen())
317715
def on_success(self, retval, task_id, args, kwargs):
        """"""
        super().on_success(retval, task_id, args, kwargs)
        self._operation_run.on_success()
458534
function postProcess( errorCode ) {
	if ( errorCode ) {
		console.error( `running npm for installing missing dependencies ${collected.join( ", " )} exited on error (${errorCode})` );
	} else if ( exec ) {
		const cmd = exec.join( " " );

		if ( !quiet ) {
			console.error( `invoking follow-up command: ${cmd}` );
		}

		const followup = Child.exec( cmd );

		followup.stdout.pipe( process.stdout );
		followup.stderr.pipe( process.stderr );

		followup.on( "exit", code => {
			process.exit( code );
		} );

		return;
	}

	process.exit( errorCode );
}
404328
def register_hook(self, event, hook):
        """"""

        if event not in self.hooks:
            raise ValueError('Unsupported event specified, with event name "%s"' % (event))

        if isinstance(hook, Callable):
            self.hooks[event].append(hook)
        elif hasattr(hook, '__iter__'):
            self.hooks[event].extend(h for h in hook if isinstance(h, Callable))
693105
def execute_hook(self, event_name):
        """"""
        hook = self.settings.hooks.get_string('{!s}'.format(event_name))
        if hook is not None and hook != "":
            hook = hook.split()
            try:
                subprocess.Popen(hook)
            except OSError as oserr:
                if oserr.errno == 8:
                    log.error("Hook execution failed! Check shebang at first line of %s!", hook)
                    log.debug(traceback.format_exc())
                else:
                    log.error(str(oserr))
            except Exception as e:
                log.error("hook execution failed! %s", e)
                log.debug(traceback.format_exc())
            else:
                log.debug("hook on event %s has been executed", event_name)
737495
def post_run(self, outline=False, dump=False, *args, **kwargs):
        """"""
        hooks = self.context.config.post_build
        handle_hooks(
            "post_build",
            hooks,
            self.provider,
            self.context,
            dump,
            outline
        )
71277
def add_done_callback(self, callback):
        
        if self._done is None or self._done.is_set():
            raise ValueError('Task has already finished')
        if callable(callback):
            self.callbacks.append(callback)
1168944
def pre_handler(self, cmd):
        """"""
        if self._finished:
            return
        if self.interesting_commit and cmd.name == 'commit':
            if cmd.mark == self.interesting_commit:
                print(cmd.to_string())
                self._finished = True
            return
        if cmd.name in self.parsed_params:
            fields = self.parsed_params[cmd.name]
            str = cmd.dump_str(fields, self.parsed_params, self.verbose)
            print("%s" % (str,))
564214
def _insert_post_complete_tasks(context):
    """"""

    logging.debug("Context %s is complete.", context.id)

    # Async event handlers
    context.exec_event_handler('complete', transactional=True)

    # Insert cleanup tasks
    try:
        # TODO: If tracking results we may not want to auto cleanup and instead
        # wait until the results have been accessed.
        from furious.async import Async
        Async(_cleanup_markers, queue=CLEAN_QUEUE,
              args=[context.id, context.task_ids],
              task_args={'countdown': CLEAN_DELAY}).start()
    except:
        pass