Open
Description
Extracted from #9822
- Ensure jobs can be terminated gracefully (store the progress somewhere), and be careful with things that shouldn't be executed twice (e.g. sending an email)
- The
BaseJob
have some default values (default timeout of 60s, backoff of 5s, etc), I think it's better to make it required instead of providing random default values. Forcing the programmer to fill in these values, it's also a good reminder to treat the exceptional cases. - It's difficult to estimate how long some jobs might run (e.g. a large installation might require much more time). So, I think the timeout should be removed (or have a really high value), if it's not possible to update the code to terminate gracefully (i.e. resume the work from where it stopped later).
- Looks like the Laravel doesn't have a
isTimedOut()
method, we could add it and update the code to respect it (e.g.while (!$this->isTimedOut()) { doWork(); }
) instead of using the$failOnTimeout = true
, it sounds better for most of the cases. IMHO abruptly timeouts are good only to catch bad code (e.g. infinite loops)...