The scheduler dosen't stop at end_time #814
Answered
by
agronholm
BabakAmini
asked this question in
Q&A
-
I'm trying to schedule a task to run each 10 seconds until the specified import logging
import pytz
from apscheduler import Scheduler
from apscheduler.triggers.cron import CronTrigger
from datetime import datetime, timedelta, timezone
logging.basicConfig()
logging.getLogger('apscheduler').setLevel(logging.DEBUG)
def fn():
tm = datetime.now().strftime('%H:%M:%S')
print(tm)
with Scheduler() as scheduler:
d = datetime.now() + timedelta(seconds=20)
end_time = d.astimezone(pytz.timezone('Europe/Paris'))
scheduler.add_schedule(fn,
CronTrigger(second='0, 10, 20, 30, 40, 50', end_time=end_time),
misfire_grace_time=None,
max_running_jobs=1)
scheduler.run_until_stopped() And here is the log:
I'm using v4.0.0a3. This is true for the asynchronous version as well. Is there anything I misunderstood? |
Beta Was this translation helpful? Give feedback.
Answered by
agronholm
Nov 9, 2023
Replies: 1 comment 13 replies
-
It's supposed to stop running the schedule after |
Beta Was this translation helpful? Give feedback.
13 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hmm...this looks like a bug in the synchronous scheduler interface. It worked for me because I had already fixed this locally. This will be rectified in the next release.
For now, you can patch the method locally: