Preparing simple worker tasks is super fast, because it just switches the state to null.
But the processing of just prepared tasks required the second worker run and also second cron run.
This change optimize the behavior and in case there is still time left it immediately starts processing the tasks.
[MAILPOET-4684]
Sometimes errors overlap each other so that the 'Last Seen error' we log
does not provide sufficient information on the cause of a problem.
E.g. one worker might cause an SQL issue, which closes the EntityManager and a
subsequent worker might overwrite this error with the information that the
EntityManager is closed.
With this commit, both those issues will be logged as an error.
[MAILPOET-4699]
CronWorkerRunner sets internal timer in its constructor function.
This works fine in classic web page request. But in integration tests
in might be created and cached in DI, so for some late running tests
it throws timeout exception.
This commit fixes the issue by using fresh instance of CronWorkerRunner
instead of "cached" one from DI container.
[MAILPOET-4274]