<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def onexit(self):
 """ Runs any "onexit" functions present in the config. This will normally be called from the proc_exit event handler after all processes in a task have stopped. Currently the following "onexit" types are supported: 'start': Set the specified task to be started. It normally would not make sense for a task to set itself to run again (that's handled by the "control" element). This handles the case where a task needs a "once" task to be rerun whenever it exits. For that reason, 'start' may only be issued against a "once" task. """

        log = self._params.get('log', self._discard)
        conf = self._config_running
        if 'onexit' not in conf:
            log.debug("Task %s has no 'onexit' processing", self._name)
            return
        if self._legion.is_exiting():
            log.debug("Skipping task %s 'onexit' processing because legion is exiting", self._name)
            return
        item = 0
        for op in conf['onexit']:
            item += 1
            if 'type' not in op:
                log.error("Task %s 'onexit' item %d has no 'type'", self._name, item)
                continue
            op_type = self._get(op.get('type'))
            if op_type == 'start':
                if 'task' not in op:
                    log.error("Task %s 'onexit' item %d type '%s' has no 'task'", self._name, item, op_type)
                    continue
                taskname = self._get(op.get('task'))
                if taskname not in self._legion._tasknames:
                    log.error("Task %s 'onexit' item %d type '%s' task '%s' does not exist",
                                        self._name, item, op_type, taskname)
                    continue
                task = None
                for t in self._legion.task_list(pending=False):
                    if taskname == t._name:
                        task = t
                if not task:
                    log.error("Task %s 'onexit' item %d type '%s' task '%s' exists but is out of scope",
                                        self._name, item, op_type, taskname)
                    continue
                if task._config_running.get('control') not in self._legion.once_controls:
                    log.error("Task %s 'onexit' item %d type '%s' task '%s' may only start 'once' tasks",
                                        self._name, item, op_type, taskname)
                    continue
                log.info("Task '%s' marked to restart by task '%s'", taskname, self._name)
                task._reset_state()
            else:
                log.error("Unknown type '%s' for task %s 'onexit' item %d", op_type, self._name, item)
                continue