""
""
"The Below Task should run every 5 minutes"
""
""
from apscheduler.schedulers.background import BackgroundScheduler
from datetime import datetime, timedelta
sched = BackgroundScheduler({'apscheduler.timezone': 'UTC',
'apscheduler.job_defaults.coalesce': 'false',
'apscheduler.job_defaults.max_instances': '1', })
def startProcess():
sched.get_jobs()
sched.remove_all_jobs()
# schedule the method 'printing_something' to run the the given 'date_time' with the args 'text'
job = sched.add_job(process, 'interval', minutes=5, replace_existing=True, max_instances=1)
sched.start()
Task ii snippet:
""
""
"The Below Task should run every Hour @ minute 10 eg. 1:10,2:10,3:10,...,23:10 everyday"
""
""
from apscheduler.schedulers.background import BackgroundScheduler
from datetime import datetime, timedelta
sched = BackgroundScheduler({'apscheduler.timezone': 'UTC',
'apscheduler.job_defaults.coalesce': 'false',
'apscheduler.job_defaults.max_instances': '1', })
def startProcess():
sched.get_jobs()
sched.remove_all_jobs()
# schedule the method 'printing_something' to run the the given 'date_time' with the args 'text'
job = sched.add_job(startaggregating, 'cron', minute=10,replace_existing=True,max_instances= 1)
sched.start()
Task iii snippet:
""
""
"The Below Task should run every day @ hour 2AM".
""
""
from apscheduler.schedulers.background import BackgroundScheduler
from datetime import datetime, timedelta
sched = BackgroundScheduler({'apscheduler.timezone': 'UTC',
'apscheduler.job_defaults.coalesce': 'false',
'apscheduler.job_defaults.max_instances': '1', })
def startProcess():
sched.get_jobs()
sched.remove_all_jobs()
# schedule the method 'printing_something' to run the the given 'date_time' with the args 'text'
job = sched.add_job(startaggregating, 'cron', hour=2, replace_existing=True, max_instances=1)
sched.start()
Task iv and v similar to i:
Hello Team,
I have implemented apscheduler in my python django project. i ran this my sever . but after someday some of these task stops unwanted without any error. but one such time i got "Schdulor Already running". please help by solving this issue.
Am i getting this issue because "max_instances=1"?
Am i getting this issue because "replace_existing=True"?
or the task is unwantedly stopping for other reasons?
thanks a lot in advance
From these snippets, it's not possible to get the "scheduler
already running" error, so I must conclude that you are showing
something else here than what you're actually running. Could you
construct a minimum viable example that we can run so it would be
possible to analyze the problem you're having?
--
You received this message because you are subscribed to the Google Groups "APScheduler" group.
To unsubscribe from this group and stop receiving emails from it, send an email to apscheduler...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/apscheduler/efbf7032-e144-4c1a-95d4-4c488ca7a5e1o%40googlegroups.com.
""
""
"The Below Task should run every 5 minutes"
""
""
from apscheduler.schedulers.background import BackgroundScheduler
from datetime import datetime, timedelta
sched = BackgroundScheduler({'apscheduler.timezone': 'UTC',
'apscheduler.job_defaults.coalesce': 'false',
'apscheduler.job_defaults.max_instances': '1', })
def startProcess():
sched.get_jobs()
sched.remove_all_jobs()
# schedule the method 'printing_something' to run the the given 'date_time' with the args 'text'
job = sched.add_job(process, 'interval', minutes=5, replace_existing=True, max_instances=1)
sched.start()
def process():
print("every 5 minutes")
Task ii snippet:
""
""
"The Below Task should run every Hour @ minute 10 eg. 1:10,2:10,3:10,...,23:10 everyday"
""
""
from apscheduler.schedulers.background import BackgroundScheduler
from datetime import datetime, timedelta
sched = BackgroundScheduler({'apscheduler.timezone': 'UTC',
'apscheduler.job_defaults.coalesce': 'false',
'apscheduler.job_defaults.max_instances': '1', })
def startProcess():
sched.get_jobs()
sched.remove_all_jobs()
# schedule the method 'printing_something' to run the the given 'date_time' with the args 'text'
job = sched.add_job(startaggregating, 'cron', minute=10,replace_existing=True,max_instances= 1)
sched.start()
def startaggregating():
print("every hour")
Task iii snippet:
""
""
"The Below Task should run every day @ hour 2AM".
""
""
from apscheduler.schedulers.background import BackgroundScheduler
from datetime import datetime, timedelta
sched = BackgroundScheduler({'apscheduler.timezone': 'UTC',
'apscheduler.job_defaults.coalesce': 'false',
'apscheduler.job_defaults.max_instances': '1', })
def startProcess():
sched.get_jobs()
sched.remove_all_jobs()
# schedule the method 'printing_something' to run the the given 'date_time' with the args 'text'
job = sched.add_job(startaggregating, 'cron', hour=2, replace_existing=True, max_instances=1)
sched.start()
def startaggregating():
print("Every day")
Task iv and v similar to i:
To unsubscribe from this group and stop receiving emails from it, send an email to apsch...@googlegroups.com.
Do you need all this for a "minimum viable" example? Your problem absolutely cannot be reproduced without trying to run all five tasks?
Also, none of the snippets even start the scheduler, so how is
this supposed to reproduce the problem?
To unsubscribe from this group and stop receiving emails from it, send an email to apscheduler...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/apscheduler/e2d68540-5caa-44d2-b4ca-16ca0f8816f8o%40googlegroups.com.
""
""
"The Below Task should run every 5 minutes"
""
""
from apscheduler.schedulers.background import BackgroundScheduler
from datetime import datetime, timedelta
sched = BackgroundScheduler({'apscheduler.timezone': 'UTC',
'apscheduler.job_defaults.coalesce': 'false',
'apscheduler.job_defaults.max_instances': '1', })
def startProcess():
sched.get_jobs()
sched.remove_all_jobs()
# schedule the method 'printing_something' to run the the given 'date_time' with the args 'text'
job = sched.add_job(process, 'interval', minutes=5, replace_existing=True, max_instances=1)
sched.start()
def process():
print("every 5 minutes")
startProcess()
Task ii snippet:
""
""
"The Below Task should run every Hour @ minute 10 eg. 1:10,2:10,3:10,...,23:10 everyday"
""
""
from apscheduler.schedulers.background import BackgroundScheduler
from datetime import datetime, timedelta
sched = BackgroundScheduler({'apscheduler.timezone': 'UTC',
'apscheduler.job_defaults.coalesce': 'false',
'apscheduler.job_defaults.max_instances': '1', })
def startProcess():
sched.get_jobs()
sched.remove_all_jobs()
# schedule the method 'printing_something' to run the the given 'date_time' with the args 'text'
job = sched.add_job(startaggregating, 'cron', minute=10,replace_existing=True,max_instances= 1)
sched.start()
def startaggregating():
print("every hour")
startProcess()
Task iii snippet:
""
""
"The Below Task should run every day @ hour 2AM".
""
""
from apscheduler.schedulers.background import BackgroundScheduler
from datetime import datetime, timedelta
sched = BackgroundScheduler({'apscheduler.timezone': 'UTC',
'apscheduler.job_defaults.coalesce': 'false',
'apscheduler.job_defaults.max_instances': '1', })
def startProcess():
sched.get_jobs()
sched.remove_all_jobs()
# schedule the method 'printing_something' to run the the given 'date_time' with the args 'text'
job = sched.add_job(startaggregating, 'cron', hour=2, replace_existing=True, max_instances=1)
sched.start()
def startaggregating():
print("Every day")
startProcess()
Task iv and v similar to i:
To view this discussion on the web visit https://groups.google.com/d/msgid/apscheduler/e2d68540-5caa-44d2-b4ca-16ca0f8816f8o%40googlegroups.com.
Are you able to reproduce the problem by running task I snippet
then? Note that the application exits immediately when it reaches
the end of the script since you are starting a background
scheduler and there is nothing preventing the main thread from
exiting.
To unsubscribe from this group and stop receiving emails from it, send an email to apscheduler...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/apscheduler/718a0052-946b-49d8-93ab-d767e0df2e59o%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/apscheduler/718a0052-946b-49d8-93ab-d767e0df2e59o%40googlegroups.com.
You have to understand that I do not have whatever mechanism you have there that runs these scripts, so there is no way for me to reproduce the same setting as you have. That's why I'm asking you to minimize these examples so that I can also see the problem as it happens.
For what it's worth, the error you're getting indicates that your
code is trying to start the scheduler twice so it's not really a
problem with APScheduler.
To unsubscribe from this group and stop receiving emails from it, send an email to apscheduler...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/apscheduler/d9592ccb-6c1d-49c5-8a0f-dfe46b0a46bdo%40googlegroups.com.