Perform an always failing task.
421255
def always_fail(cls, request) -> [
            (200, 'Ok', String),
            (406, 'Not Acceptable', Void)]:
        ''''''
        task_id = uuid4().hex.upper()[:5]
        log.info('Starting always FAILING task {}'.format(task_id))
        for i in range(randint(0, MAX_LOOP_DURATION)):
            yield
        Respond(406)
        Respond(200, 'Foobar')
801958
public function fail($exception)
    {
        $this->resqueInstance->events->trigger('onFailure', [
            'exception' => $exception,
            'job' => $this
        ]);

        if(isset($this->status)) {
            $this->status->update(ResqueJobStatus::STATUS_FAILED);
        }

        $this->resqueInstance->stats->incr('failed');
        $this->resqueInstance->stats->incr('failed:' . $this->worker);
        if ($this->resqueInstance->backend->recreateFailedJobs) {
            $this->recreate();
        }
    }
1067567
def on_failure(self, exc, task_id, args, kwargs, einfo):
        
        log.error('[{}] failed due to {}'.format(task_id, getattr(einfo, 'traceback', None)))
        super(LoggedTask, self).on_failure(exc, task_id, args, kwargs, einfo)
123221
public function fail()
    {
        $args = func_get_args();
        $str = ucfirst(
            $this->prefix.
            ($this->caption ?: str_replace('_', ' ', $this->active_field)).' '.
            lcfirst(array_shift($args))
        );

        // Insert any args into placeholders
        if (count($args) > 0) {
            $n = 1;

            foreach ($args as $arg) {
                $tag = sprintf('{{arg%s}}', $n);
                $str = str_replace($tag, $arg, $str);
                ++$n;
            }
        }

        /** @type Exception_ValidityCheck $e */
        $e = $this->exception((string) ($this->custom_error ?: $str));
        throw $e->setField($this->active_field);
    }
320470
def issue(self, test, err):
        """"""
        self.step.setProgress('tests failed', len(self.failures) +
                              len(self.errors))
989643
def wait_for_success(self, interval=1):
        

        self.wait_for_completion(interval=interval)

        if not self.is_successful(retry=True):
            for task_name, task in six.iteritems(self.get_task_statuses()):
                exc = None
                if task.status == Instance.Task.TaskStatus.FAILED:
                    exc = errors.parse_instance_error(self.get_task_result(task_name))
                elif task.status != Instance.Task.TaskStatus.SUCCESS:
                    exc = errors.ODPSError('%s, status=%s' % (task_name, task.status.value))
                if exc:
                    exc.instance_id = self.id
                    raise exc
259977
def _do_cb(self, task, cb, error_cb, *args, **kw):
        
        try:
            res = self.work(task, *args, **kw)
        except BackendProcessingError as e:
            if error_cb is None:
                self.log(ERROR, e.__traceback__)
                show_err()
            elif error_cb:
                error_cb(e)
        else:
            # Success, let's call away!
            cb(res)
1190667
def raise_on_failure(mainfunc):
    """"""
    try:
        errors = mainfunc()
        if errors:
            exit(errors)
    except CalledProcessError as error:
        exit(error.returncode)
    except SystemExit as error:
        if error.code:
            raise
    except KeyboardInterrupt:  # I don't plan to test-cover this.  :pragma:nocover:
        exit(1)
445595
def run(self):
        """"""
        self.exc = None
        try:
            self.task()
        except BaseException:
            self.exc = sys.exc_info()
104203
protected void start() {
        // if a periodic execution throws an exception, future executions are suspended,
        // this task wraps the call in a try-catch block to prevent that. Errors are still propagated.
        final Runnable resilientTask = () -> {
            try {
                run();
            } catch (final Exception e) {
                logger.error("[{}] Error during timeout-initiated flush", name, e);
            }
        };

        scheduler.scheduleAtFixedRate(resilientTask, 0, batchTimeout + salt, TimeUnit.MILLISECONDS);
    }
162755
def task(name, deps = None, fn = None):
	""""""
	if callable(deps):
		fn = deps
		deps = None

	if not deps and not fn:
		logger.log(logger.red("The task '%s' is empty" % name))
	else:
		tasks[name] = [fn, deps]
387561
private void failTask(final ExecutionAttemptID executionAttemptID, final Throwable cause) {
		final Task task = taskSlotTable.getTask(executionAttemptID);

		if (task != null) {
			try {
				task.failExternally(cause);
			} catch (Throwable t) {
				log.error("Could not fail task {}.", executionAttemptID, t);
			}
		} else {
			log.debug("Cannot find task to fail for execution {}.", executionAttemptID);
		}
	}
442054
def fail(message, code=-1):
    """"""
    print('Error: %s' % message, file=sys.stderr)
    sys.exit(code)
1155661
def _fire_task(self, exclude=None):
        """"""
        connection = mail.get_connection(fail_silently=True)
        # Warning: fail_silently swallows errors thrown by the generators, too.
        connection.open()
        for m in self._mails(self._users_watching(exclude=exclude)):
            connection.send_messages([m])
1323370
def create_failure(self, exception=None):
        
        if exception:
            return FailedFuture(type(exception), exception, None)
        return FailedFuture(*sys.exc_info())
1158345
def alwaysThrew(cls, spy, error_type=None): #pylint: disable=invalid-name
        
        cls.__is_spy(spy)
        if not (spy.alwaysThrew(error_type)):
            raise cls.failException(cls.message)
1369191
public void logTaskFailed(TaskID taskId, String taskType, long time,
      String error) {
    logTaskFailed(taskId, taskType, time, error, null);
  }