Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

conflicts with an existing job #24

Closed
weiguang-zz opened this issue Oct 20, 2016 · 2 comments
Closed

conflicts with an existing job #24

weiguang-zz opened this issue Oct 20, 2016 · 2 comments

Comments

@weiguang-zz
Copy link

I have the Config like this:

class Config(object):
    JOBS = [
        {
            'id': 'job9',
            'func': 'sync:job1',
            'args': (1, 2),
            'trigger': 'interval',
            'seconds': 10
        }
    ]

    SCHEDULER_JOBSTORES = {
        'default': SQLAlchemyJobStore(url='sqlite:///'+utils.get_absolute_path("datas/jobstore.db"))
    }

    SCHEDULER_EXECUTORS = {
        'default': {'type': 'threadpool', 'max_workers': 20}
    }

    SCHEDULER_JOB_DEFAULTS = {
        'coalesce': False,
        'max_instances': 3
    }

    SCHEDULER_VIEWS_ENABLED = True

So, when i start the scheduler, it will insert the job in the sqlite. however, when i restart the scheduler, it will insert again, which will cause an exception:

Traceback (most recent call last):
  File "/Users/zhangzheng/PycharmProjects/quant/mainapp.py", line 73, in <module>
    scheduler.start()
  File "/Users/zhangzheng/pyenv/tensorflow/lib/python2.7/site-packages/flask_apscheduler/scheduler.py", line 81, in start
    self.__scheduler.start()
  File "/Users/zhangzheng/pyenv/tensorflow/lib/python2.7/site-packages/apscheduler/schedulers/background.py", line 33, in start
    BaseScheduler.start(self, *args, **kwargs)
  File "/Users/zhangzheng/pyenv/tensorflow/lib/python2.7/site-packages/apscheduler/schedulers/base.py", line 151, in start
    self._real_add_job(job, jobstore_alias, replace_existing)
  File "/Users/zhangzheng/pyenv/tensorflow/lib/python2.7/site-packages/apscheduler/schedulers/base.py", line 847, in _real_add_job
    store.add_job(job)
  File "/Users/zhangzheng/pyenv/tensorflow/lib/python2.7/site-packages/apscheduler/jobstores/sqlalchemy.py", line 94, in add_job
    raise ConflictingIdError(job.id)
apscheduler.jobstores.base.ConflictingIdError: u'Job identifier (job9) conflicts with an existing job'

I think this isn't the right way when I start a scheduler. the right way should be inserting a job when the store not exist or just skip it. beacuse, when my app is done, i want to resume the existing job when i restart it.

zhangzheng

@viniciuschiele
Copy link
Owner

Hi @zhangzheng88

If your tasks are in the config file, why are you storing them in sqlite? It seems redundant.

@weiguang-zz
Copy link
Author

you are right, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants