Will using sched.add_job with same time and date trigger for two different jobs run both of them? If not, how can I add the second job with a different trigger time using the same Background scheduler?
You can use apscheduler to execute two jobs at the same time:
from flask import Flask
import atexit
from apscheduler.schedulers.background import BackgroundScheduler
scheduler = BackgroundScheduler()
def job1():
for _ in range(1000):
print('a')
def job2():
for _ in range(1000):
print('b')
h = 10
m = 0
# set h,m to the time you are ready to test
scheduler.add_job(job1,'cron',hour=h,minute=m)
scheduler.add_job(job2,'cron',hour=h,minute=m)
scheduler.start()
atexit.register(lambda: scheduler.shutdown())
app = Flask(__name__)
if __name__ == "__main__":
app.run()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With