Comments (13)
Are you using one single .py file to initialise the scheduler and to define your task? If so, it is not going to work because APScheduler will reload the same .py file and it will re-instantiate all your objects.
Split your project in two files, like app.py and tasks.py
app.py initialises Flask and APScheduler and in tasks.py you put your task methods.
I hope this works for you.
from flask-apscheduler.
And also the way you built this code, the variable scheduler
is not accessible within your task.
from flask-apscheduler.
so are you saying that scheduler.delete_job('job1') is the right way of unscheduling a job?
and if jobstore in my config, like this
class Config(object):
JOBS = [
{
'id': 'job1',
'func': 'sjobs:job1',
'args': ("Shrey"),
'trigger': 'interval',
'seconds': 5
}
]
SCHEDULER_JOBSTORES = {
'default': SQLAlchemyJobStore(url='postgresql://postgres:postgres@localhost:5432/scheduler',tablename='apscheduler')
}
I have this config, with a jobstore(taken from example, just changed sqlite to postgres), do I have to give the jobstore name in the delete call, if yes then what it is? basically i want to delete the job from the jobstore
and one more doubt is, is there a way to delete a job from inside the job, without using the id....something like self.id gives id of the running job, or any workaround for that?
from flask-apscheduler.
You don't need to give the jobstore name, just call delete_job passing the job name.
Unfortunately there is no way to get the current job within a job using self
, if you really need that, you can open an issue for APScheduler
from flask-apscheduler.
so does delete_job(id) deletes the job from jobstore, or it just stop executing it?
from flask-apscheduler.
it will delete the job and stop executing it.
from flask-apscheduler.
Thanks man...its working well
One more doubt that I have though, what about HA(High availability) is there anything can be done from APscheduler's point of view, like db sync or something which makes sure that it never goes down
from flask-apscheduler.
No, APScheduler doesn't give any HA feature, you need to do it by yourself.
In my company we use uwsgi legion to keep one server as active and the others as stand by, so if the active server fails, uwsgi legion will start the APScheduler App in one of the other servers.
from flask-apscheduler.
from flask-apscheduler.
You are right, legion is for any application.
If the server fails it will bring up all apps that are part of this legion on the other server.
I'm not aware of the details because we have a system engineer that manages that for us.
As long as your jobs are stored in database, you shouldn't have any issue.
from flask-apscheduler.
alright...thanks man
But before we close this discussion one naive doubt?
Say I dont have a legion setup done and I have a restful app which has apshceduler running in it, and I have 2 instances of the app running on 2 servers with the shared database, basically jobstore is same....so if a job gets scheduled, it will be served by both the apps right? or which ever server picks it up ony that will execute it...
from flask-apscheduler.
Hi,
Yeah, it will probably run by both apps.
from flask-apscheduler.
thanks man, we can close this
from flask-apscheduler.
Related Issues (20)
- Running job causes detachedinstanceerror HOT 3
- Use Codecov in informational mode HOT 1
- APScheduler not working with gunicorn eventlet HOT 6
- Flask 2.3.2 causing KeyError: 'JSONIFY_PRETTYPRINT_REGULAR' HOT 1
- Flask-APScheduler multiple jobs running at the same time when having multiple workers HOT 1
- [RFE] Package python3-flask-apscheduler into RPM
- KeyError: 'JSONIFY_PRETTYPRINT_REGULAR' when running Flask as a development server HOT 2
- Apscheduler not working with flask debug=True & --no-reload
- Flask 3.0.0 support HOT 1
- Behaviour of processpool HOT 1
- Key Error while passing redis instance as arg HOT 2
- Can't start BlockingScheduler as daemon in debug mode
- Issue with sqlalchemy (cannot join current thread and working outside of app context) HOT 4
- python3-flask-APScheduler_1.13.0.bb HOT 4
- Can I use hive database to restore jobs? HOT 2
- Coroutine as argument
- use api add task func which is not defined in the app start script failed HOT 2
- alembic migrations
- ModuleNotFoundError: No module named 'flask_apscheduler' HOT 2
- Adding a pyproject.toml to ensure compliance with updates to pip
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 flask-apscheduler.