GithubHelp home page GithubHelp logo

The enabled interval schedule is not triggering If we add new Periodic Tasks to the database about celery-sqlalchemy-scheduler HOT 5 CLOSED

angelliang avatar angelliang commented on September 22, 2024
The enabled interval schedule is not triggering If we add new Periodic Tasks to the database

from celery-sqlalchemy-scheduler.

Comments (5)

AngelLiang avatar AngelLiang commented on September 22, 2024

You added new Periodic Tasks by database tool, or by PeriodicTask Model?

you can read example code 1 for more detail.

>>> import json
>>> from celery_sqlalchemy_scheduler.models import PeriodicTask, IntervalSchedule
>>> from celery_sqlalchemy_scheduler.session import SessionManager
>>> beat_dburi = 'sqlite:///schedule.db'
>>> session_manager = SessionManager()
>>> engine, Session = session_manager.create_session(beat_dburi)
>>> session = Session()
# Disable 'echo-every-3-seconds' task
>>> task = session.query(PeriodicTask).filter_by(name='echo-every-3-seconds').first()
>>> task.enabled = False
>>> session.add(task)
>>> session.commit()
>>> schedule = session.query(IntervalSchedule).filter_by(every=10, period=IntervalSchedule.SECONDS).first()
>>> if not schedule:
...     schedule = IntervalSchedule(every=10, period=IntervalSchedule.SECONDS)
...     session.add(schedule)
...     session.commit()
# Add 'add-every-10s' task
>>> task = PeriodicTask(
...     interval=schedule,
...     name='add-every-10s',
...     task='tasks.add',  # name of task.
...     args=json.dumps([1, 5])
... )
>>> session.add(task)
>>> session.commit()
>>> print('Add ' + task.name)
Add add-every-10s
>>> task.args=json.dumps([10, 2])
>>> session.add(task)
>>> session.commit()

from celery-sqlalchemy-scheduler.

DarshanLukhi avatar DarshanLukhi commented on September 22, 2024

@AngelLiang, I added periodic task PeriodicTask Model.

from celery-sqlalchemy-scheduler.

DarshanLukhi avatar DarshanLukhi commented on September 22, 2024
        self.total_run_count = model.total_run_count
        self.enabled = model.enabled

        if not model.last_run_at:
            model.last_run_at = self._default_now()
        self.last_run_at = model.last_run_at

        # 因为从数据库读取的 last_run_at 可能没有时区信息,所以这里必须加上时区信息
        # self.last_run_at = self.last_run_at.replace(tzinfo=self.app.timezone)

If I remove above commented line then it's working fine.
It seems time not converted to localized timezone not done because of commented line.

from celery-sqlalchemy-scheduler.

AngelLiang avatar AngelLiang commented on September 22, 2024

Maybe a bug. you can read this PR for detail.

Some bugs are related to timezones, but I can't fix they well. So welcome PR if you like.

from celery-sqlalchemy-scheduler.

AngelLiang avatar AngelLiang commented on September 22, 2024

I rollback the commented line and release v0.2.6.
Maybe some database don't save timezone throught sa.DateTime(timezone=True).

from celery-sqlalchemy-scheduler.

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.