On Tue, Jul 7, 2015 at 10:28 AM, Henning Vreyborg <
[email protected]> wrote:

> I want to have my job reexecuted after it fails. Is my solution of
> adding a clone to the job queue viable? For me it feels a bit dirty.
>
> class CreateTicketJob extends Job {
>         [...]
>         public function run( )
>         {
>                 [...]
>
>                 if (/* job failed due to not connecting to external
> resource */) {
>                         $job = new CreateTicketJob( $this->getTitle(),
> $this->params );
>
>                         return JobQueueGroup::singleton()->push( $job );
>                 }
>                 return true;
>         }
>         [...]
> }
>

That's how GWToolset <https://www.mediawiki.org/wiki/Extension:GWToolset> does
it (for a different purpose). It is indeed dirty, but it works. It makes
the job hard to kill though, so you might want to build in some safety
mechanism to avoid involuntary DOS attacks.
_______________________________________________
Wikitech-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

Reply via email to