Giter Club home page Giter Club logo

Comments (8)

viniciuschiele avatar viniciuschiele commented on July 18, 2024

Hi,

If you have your tasks in the config.py and you are using a persisted job store (sqlalchemy, mongodb...), every time you run your app Flask-APScheduler will try to add again those jobs to the job store and it will raise an error because the jobs already exist there.

from flask-apscheduler.

spitfiredd avatar spitfiredd commented on July 18, 2024

Should I keep the config for Flask-APScheduler in the file I create my app in?

from flask-apscheduler.

viniciuschiele avatar viniciuschiele commented on July 18, 2024

Hi,

If you want to keep your jobs in the config file you can use replace_existing: True, it will override the jobs in the job store every time your app runs.

If you don't want this behavior you can't keep the jobs in the config file.

from flask-apscheduler.

spitfiredd avatar spitfiredd commented on July 18, 2024

Well, maybe my issue is not with the jobs but with the Jobstore?? Because now I am running into errors when I try your examples. For example, either advanced.py or flask_context.py give me the error,

Traceback (most recent call last):
  File "test.py", line 47, in <module>
    scheduler.start()
  File "C:\Anaconda3\envs\g2x_flask\lib\site-packages\flask_apscheduler\scheduler.py", line 82, in start
    self._scheduler.start()
  File "C:\Anaconda3\envs\g2x_flask\lib\site-packages\apscheduler\schedulers\background.py", line 33, in start
    BaseScheduler.start(self, *args, **kwargs)
  File "C:\Anaconda3\envs\g2x_flask\lib\site-packages\apscheduler\schedulers\base.py", line 154, in start
    self._real_add_job(job, jobstore_alias, replace_existing)
  File "C:\Anaconda3\envs\g2x_flask\lib\site-packages\apscheduler\schedulers\base.py", line 851, in _real_add_job
    store.add_job(job)
  File "C:\Anaconda3\envs\g2x_flask\lib\site-packages\apscheduler\jobstores\sqlalchemy.py", line 94, in add_job
    raise ConflictingIdError(job.id)
apscheduler.jobstores.base.ConflictingIdError: 'Job identifier (job1) conflicts with an existing job'

It works the first time it runs, but then when I run the script again that is when I get the error, with advanced.py this happens when I change from url='sqlite://' to something persistant, ie url='sqlite://.test.db'

Is there something I am doing wrong running your examples?

Also, I am not even sure if this is an issue with your package since the errors seem to be coming from apscheduler and not flask-apscheduler?

from flask-apscheduler.

viniciuschiele avatar viniciuschiele commented on July 18, 2024

It doesn't work, you can't put your jobs in the config file and use a persisted job store because every time you run your app it will try to add your jobs in the job store.

An alternative would be using replace_existing: True

from flask-apscheduler.

spitfiredd avatar spitfiredd commented on July 18, 2024

I see. What is the point of having a job in a database? Is it even required?

from flask-apscheduler.

viniciuschiele avatar viniciuschiele commented on July 18, 2024

For example, if you have a job to run every hour and the next trigger is 14:00, if for some reason you had to stop and start your app 5 minutes before (like 13:55), the next trigger is going be 14:55 and not 14:00 as before.

That would happen if you didn't use a persistent job store, It may be an issue in some scenarios.

from flask-apscheduler.

viniciuschiele avatar viniciuschiele commented on July 18, 2024

Feel free to reopen it again if you need it.

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.