Giter Club home page Giter Club logo

Comments (4)

securitypedant avatar securitypedant commented on July 19, 2024 1

Thanks Christopher, will try this out.

from flask-apscheduler.

christopherpickering avatar christopherpickering commented on July 19, 2024

Can you give your job an id, and then check the jobstore for the id's status before running? Setting the max instances to 1 should prevent the scheduler from running the chron job at the same time as a user triggering the job.

https://apscheduler.readthedocs.io/en/3.x/userguide.html#adding-jobs

from flask-apscheduler.

securitypedant avatar securitypedant commented on July 19, 2024

That would be a way to prevent my manual job from running. However, the piece I need to figure out is, for the manual job, I want to run an existing scheduler job on demand. So that if the scheduled job runs, it see's a job was already started... for example...

0 mins - SpeedTest runs on schedule
5 mins - SpeedTest runs on schedule
10 mins - SpeedTest runs on schedule
14 mins - SpeedTest run manually from UX
15 mins - SpeedTest runs on schedule, see's a manual start of the same job already running and therefore doesn't run.

I need something like

scheduler.job('jobid').run()

So I can start a scheduled job whenever, irrespective of the schedule.

from flask-apscheduler.

christopherpickering avatar christopherpickering commented on July 19, 2024

To run a function on demand you can submit it as a "one off" job with the current time as the start time.
https://apscheduler.readthedocs.io/en/3.x/modules/triggers/date.html#module-apscheduler.triggers.date

You will have one function that setups the cron/interval job, and one function for the one-off run.
Both will call the same function and have the same id. When the job is manually triggered, before sending it to the scheduler you could check the id. I'm not 100% sure what the max instances will do when you try to add more than one (will it queue them or just ignore it?) > you can find in the docs, it is possible that the max instances will solve all the problems.

from flask-apscheduler.

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.