Open Trung0246 opened 6 months ago
[X] I have checked that my issue does not already have a solution in the FAQ
[X] I have searched the existing issues and didn't find my bug already reported there
[X] I have checked that my bug is still present in the latest release
4.0.0a4
How the schedule was created:
TRACK_ENGINE = sqlalchemy.ext.asyncio.create_async_engine(f"sqlite+aiosqlite:///{schedule_path}") pathlib.Path(schedule_path).parent.mkdir(parents=True, exist_ok=True) TRACK_DB = apscheduler.datastores.sqlalchemy.SQLAlchemyDataStore( engine=TRACK_ENGINE, ) async with apscheduler.AsyncScheduler(data_store=TRACK_DB) as scheduler: TRACK_SCHEDULE = scheduler await TRACK_SCHEDULE.add_schedule( track_handle, apscheduler.triggers.interval.IntervalTrigger( weeks=data.get("weeks", 0), days=data.get("days", 0), hours=data.get("hours", 0), minutes=data.get("minutes", 0), seconds=data.get("seconds", 0), microseconds=data.get("microseconds", 0), start_time=data.get("start_time", datetime.datetime.now()), end_time=data.get("end_time", None), ), max_running_jobs = 1, conflict_policy = apscheduler.ConflictPolicy.do_nothing )
The schedule termination mechanism:
await asyncio.gather(TRACK_SCHEDULE.stop(), TRACK_SCHEDULE.wait_until_stopped())
This only happens when the job is RUNNING, not when it's finished and therefore we can safely cancel during that time span.
Use the above code to plug in appropriate order. When TRACK_SCHEDULE restarted with new python runtime instance, the job no longer getting created.
TRACK_SCHEDULE
The problem is probably this:
Looks like running_jobs is still at 1 despite the job being cancelled.
running_jobs
Can you reproduce this on master? I've made TONS of changes around this area, and the problem may not exist anymore. If it does, would you mind creating a minimal working example for me?
Things to check first
[X] I have checked that my issue does not already have a solution in the FAQ
[X] I have searched the existing issues and didn't find my bug already reported there
[X] I have checked that my bug is still present in the latest release
Version
4.0.0a4
What happened?
How the schedule was created:
The schedule termination mechanism:
How can we reproduce the bug?
This only happens when the job is RUNNING, not when it's finished and therefore we can safely cancel during that time span.
Use the above code to plug in appropriate order. When
TRACK_SCHEDULE
restarted with new python runtime instance, the job no longer getting created.The problem is probably this:
Looks like
running_jobs
is still at 1 despite the job being cancelled.