Giter Site home page Giter Site logo

Comments (6)

Guikingone avatar Guikingone commented on June 12, 2024 1

Actually, there might be a solution (note that I use "might" and not "there's a solution" 😄):

  • When retrieving tasks using getDueTasks(), we can filter the results using last_execution option, this one is set using a DatetimeImmutable each time that the task is executed.

Maybe that we can do something like this:

Given the current date (using a specific format)
When I retrieve the due tasks 
And that I filter each one using CronExpression()->isDue()
And that I check if the current date (close to the current minute) does not equal the last execution of the task
Then I should find a set of tasks (or none if tasks have already been executed

WDYT?

from schedulerbundle.

jvancoillie avatar jvancoillie commented on June 12, 2024

after search, it is a limit of the cron-expression parser, the isDue() method does not take seconds into account.

/**
 * Determine if the cron is due to run based on the current date or a
 * specific date.  This method assumes that the current number of
 * seconds are irrelevant, and should be called once per minute.
 *
 * @param string|\DateTimeInterface $currentTime Relative calculation date
 * @param null|string               $timeZone    TimeZone to use instead of the system default
 *
 * @return bool Returns TRUE if the cron is due to run or FALSE if not
 */

So, when I run several scheduler:consume in the same minute the task is executed each time.

(and should be called once per minute)

Is it a problem ? do we need to add a check for this ?

from schedulerbundle.

Guikingone avatar Guikingone commented on June 12, 2024

Hum, currently and apart from the scheduler:consume command, I don't know how to bypass this limitation, maybe we can pause the worker (thanks to sleep) until the next minute but the issue is located in the scheduler, not the worker.

Regarding the getDueTasks() method, I don't know how to add a check in it, maybe via a flag (maybe hasBeenCalled?) or an attribute but for me, the issue is related to the external library, not the bundle 🙁

from schedulerbundle.

jvancoillie avatar jvancoillie commented on June 12, 2024

yes i agree with you i don't see how to improve that. you can close this request if you wish

from schedulerbundle.

Guikingone avatar Guikingone commented on June 12, 2024

Hi @jvancoillie

I'm gonna merge the fix this morning, should be released in 0.4.5 🙂

from schedulerbundle.

jvancoillie avatar jvancoillie commented on June 12, 2024

great new ! will test this soon 😉

from schedulerbundle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.