Comments (1)
This is a known issue celery/celery#4806. The gist of it is that when a change is made to any one of your scheduled tasks, beat then reloads the table to make sure everything is current. In doing so it also ends up checking the last_ran_at timestamp and if too much time has elapsed it schedules it for execution. There's some logic issues with how that works. There's a larger work around in the same issue that you can use if you want to fork your own copy. Note that this can also happen if you restart beat in the same timeframe.
The way I've been able to work around it, on start up or changes made to any one of my scheduled entries, I basically just set last_run_at to null. As the logic for last_run_at wont trigger an execution if its the 'first time'. Of course this creates an issue if you actually care about the last execution time. Here my use case it doesn't matter to have this viewable by anyone as I have flower to track all my tasks executions as well as a custom audit table.
This is what my start up of beat looks like (replace SessionManager() with whatever your db connection is):
@beat_init.connect
def reset_last_run(**_):
"""
Reset all the last ran times in celery database. This is to prevent accidental runs if a new service is deployed
or restarted.
"""
logging.info("Resetting last run at for Periodic Task table")
with SessionManager() as session:
periodic_tasks = session.query(PeriodicTask).all()
for pt in periodic_tasks:
pt.last_run_at = None
session.add(pt)
session.commit()
from celery-sqlalchemy-scheduler.
Related Issues (20)
- Crontab Error HOT 1
- Dynamic update of the celery_crontab_schedule table? HOT 4
- Interval task 恢复enabled无法send task HOT 1
- The enabled interval schedule is not triggering If we add new Periodic Tasks to the database HOT 5
- 是否可以动态的添加修改定时任务 HOT 3
- Recursion error on repr for IntervalSchedule object HOT 1
- crontab 任务不发送 HOT 2
- Deleted schedule isn't removed from DatabaseScheduler.schedule in memory HOT 3
- celery-sqlalchemy-scheduler not working with ver 5.0.1 of Celery HOT 6
- Periodic tasks are being deleted. HOT 3
- Beat
- Future date periodic task blocking other tasks
- Beat was unable to find crontab task in the database HOT 1
- 新增任务或者修改状态,beat会报错并中止进程 HOT 1
- `celery_sqlalchemy_scheduler` does not run att all.
- "Connection is busy" error with SQL Server connection HOT 1
- CrontabSchedule addition in PeriodicTask gives error
- 更改了start_time以后会暂停所有任务的调度
- 疑似expires字段不生效 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from celery-sqlalchemy-scheduler.