Skip to content

Commit e8c5248

Browse files
authored
Avoid crash when removing job which might not exist in async_.py
I found a scenario once though harder to reproduce that scheduler crashes when a job runs longer than the schedule which has an interval of say 1 minute. I believe the duration is lesser important, but it is possible that the job runs longer than 1 minute and when the time comes to remove it then it do not exist and calling python `set.remove(id)` crashes the scheduler which should not be so. Hence protecting it.
1 parent d01ad31 commit e8c5248

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/apscheduler/_schedulers/async_.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1216,4 +1216,4 @@ async def _run_job(self, job: Job, func: Callable[..., Any], executor: str) -> N
12161216
finally:
12171217
current_job.reset(token)
12181218
finally:
1219-
self._running_jobs.remove(job)
1219+
self._running_jobs.discard(job)

0 commit comments

Comments
 (0)