TaskSchedulerBundle
TaskSchedulerBundle copied to clipboard
Printing in initialize function cancels CRON's recurrency
Any kind of text printing (echo, print_r, var_dump) used in a task's initialize()
will make it's Cron
fire every minute instead of the configured expression.
However, the Cron
's expression is the configured one and isDue
is TRUE
.
Log says task is run as usual.
This is not so bad, but you have to know.
Why would it run every 5 minutes when printing something ? Why precisely 5 minutes ? Any source code to show? Thanks
I didn't say « five (5) » but « fire ». Sorry for the misunderstanding. In other words, the task is run every minute (* * * * *) no matter how it is scheduled.
is this still relevant?
I experimented it a few months ago, and yes it is the case. I didn't have time to fill in a PR so I had to workaround with supervisord
but that should definetely be fixed with a major version bump as it would probably break backward compatibility.
i just want to confirm something.
you run cron every minute, this cron starts a process, that searches all classes extending interface using symfony's tagging for every found class it tries to determine if it should be run in current minute and in consequence launches initialize method to check it ( and here print or var_dump happens ). now assumption is that if task should not be run, it won't, but it happens anyway, right?
I mean, it should work like that: initialize will be run, but it does not means, that task was run, but the effect is, that task is run anyway?
What makes you think that a task is run all the time? run
of a task is only executed if isDue
returns true. If you have seen other behaviour, can you share sample code that triggers this?
Even that search for all scheduled tasks should not happen every time, but only once (during container build time)
anyway, I tried with both, echo and var dump and it works as expected, task is not run, and echo is printed at kernel boot (and that happens every time you run ts:run command, but it doesn't mean that task is run by itself).
src/**/Task/LoadOpenOrdersTask.php:47:
string(3) "aaa"
22:51:56 INFO [scheduler] [08/02/21 22:51:56] Starting...
22:51:57 INFO [scheduler] Skipped App\**\Task\LoadOpenOrdersTask
22:51:57 INFO [scheduler] Running App\**\Task\SendPriceListTask
can you run ts:run with more verbose logger (-vvv) and/or provide code that triggers this?
should we just close this?