apscheduler: asyncio.exceptions.CancelledError: Cancelled by cancel scope 7f27c9d9bbe0

Things to check first

  • I have checked that my issue does not already have a solution in the FAQ

  • I have searched the existing issues and didn’t find my bug already reported there

  • I have checked that my bug is still present in the latest release

Version

4.0.0a4

What happened?

In random moment scheduler is crashing and throw this error:

api      | 2024-01-01 14:22:34,081 | INFO     | apscheduler._schedulers.async_:917 - Job 01e098c6-6d31-4ad4-9cf5-f331670c11fe was cancelled
api      | 2024-01-01 14:22:34,096 | ERROR    | apscheduler._schedulers.async_:693 - Scheduler crashed
api      |   + Exception Group Traceback (most recent call last):
api      |   |   File "/usr/local/lib/python3.10/site-packages/apscheduler/_schedulers/async_.py", line 667, in run_until_stopped
api      |   |     async with create_task_group() as task_group:
api      |   |   File "/usr/local/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 678, in __aexit__
api      |   |     raise BaseExceptionGroup(
api      |   | exceptiongroup.ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)
api      |   +-+---------------- 1 ----------------
api      |     | Traceback (most recent call last):
api      |     |   File "/usr/local/lib/python3.10/site-packages/apscheduler/_schedulers/async_.py", line 889, in _process_jobs
api      |     |     await wakeup_event.wait()
api      |     |   File "/usr/local/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 1641, in wait
api      |     |     await self._event.wait()
api      |     |   File "/usr/local/lib/python3.10/asyncio/locks.py", line 214, in wait
api      |     |     await fut
api      |     | asyncio.exceptions.CancelledError: Cancelled by cancel scope 7f27c9de4f40
api      |     |
api      |     | During handling of the above exception, another exception occurred:
api      |     |
api      |     | Exception Group Traceback (most recent call last):
api      |     |   File "/usr/local/lib/python3.10/site-packages/apscheduler/_schedulers/async_.py", line 863, in _process_jobs
api      |     |     async with AsyncExitStack() as exit_stack:
api      |     |   File "/usr/local/lib/python3.10/contextlib.py", line 714, in __aexit__
api      |     |     raise exc_details[1]
api      |     |   File "/usr/local/lib/python3.10/contextlib.py", line 697, in __aexit__
api      |     |     cb_suppress = await cb(*exc_details)
api      |     |   File "/usr/local/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 678, in __aexit__
api      |     |     raise BaseExceptionGroup(
api      |     | exceptiongroup.ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)
api      |     +-+---------------- 1 ----------------
api      |       | Traceback (most recent call last):
api      |       |   File "/usr/local/lib/python3.10/site-packages/apscheduler/_schedulers/async_.py", line 966, in _run_job
api      |       |     self._running_jobs.remove(job.id)
api      |       | KeyError: UUID('482d3fd1-1095-4d51-8c24-2e33e1ad7c3c')
api      |       +------------------------------------
api      | 2024-01-01 14:22:34,104 | ERROR    | uvicorn.error:134 - Traceback (most recent call last):
api      |   File "/usr/local/lib/python3.10/site-packages/starlette/routing.py", line 714, in lifespan
api      |     await receive()
api      |   File "/usr/local/lib/python3.10/site-packages/uvicorn/lifespan/on.py", line 137, in receive
api      |     return await self.receive_queue.get()
api      |   File "/usr/local/lib/python3.10/asyncio/queues.py", line 159, in get
api      |     await getter
api      | asyncio.exceptions.CancelledError: Cancelled by cancel scope 7f27c9d9bbe0

Scheduler was tried to remove running job, but was throw error KeyError: UUID('482d3fd1-1095-4d51-8c24-2e33e1ad7c3c')

How can we reproduce the bug?

I dont know how to reproduce this bug, it’s working always with SqlalchemyDatastore

About this issue

  • Original URL
  • State: closed
  • Created 6 months ago
  • Comments: 35 (18 by maintainers)

Most upvoted comments

I was able to reproduce the KeyError: UUID('469d2e0f-2b9f-40ca-9b2b-df73e87d0d8d') even with the default in-memory data store.