You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.0a5post80
What happened?
We're using version 4.0.0a5.post80 of apscheduler and discovered an issue when configuring tasks on a scheduler passing a "Task" object. Basically, the Callable I'm passing is not stored as part of the Scheduler Task.
import asyncio
from apscheduler import AsyncScheduler, Task
async def my_func():
print("Hello World")
return 42
async def main():
async with scheduler as s:
# Generate the Task object
the_task = Task(id="test", func="__main__:my_func", job_executor="threadpool")
# Register the Task with the Scheduler
await s.configure_task(the_task)
# print the tasks
# Note that this line returns something like this:
# [Task(id='test', func=None, job_executor='threadpool', max_running_jobs=None, misfire_grace_time=None, metadata={}, running_jobs=0)]
print(await s.get_tasks())
await s.add_job("test")
await scheduler.run_until_stopped()
asyncio.run(main())
Scheduler crashed
+ Exception Group Traceback (most recent call last):
| File "/workspaces/myproject/.venv/lib/python3.12/site-packages/apscheduler/_schedulers/async_.py", line 784, in run_until_stopped
| async with create_task_group() as task_group:
| ^^^^^^^^^^^^^^^^^^^
| File "/workspaces/myproject/.venv/lib/python3.12/site-packages/anyio/_backends/_asyncio.py", line 763, in __aexit__
| raise BaseExceptionGroup(
| ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)
+-+---------------- 1 ----------------
| Traceback (most recent call last):
| File "/workspaces/myproject/.venv/lib/python3.12/site-packages/apscheduler/_schedulers/async_.py", line 1012, in _process_jobs
| func = self._get_task_callable(task)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| File "/workspaces/myproject/.venv/lib/python3.12/site-packages/apscheduler/_schedulers/async_.py", line 974, in _get_task_callable
| raise CallableLookupError(
| apscheduler._exceptions.CallableLookupError: Task test requires a locally defined callable to be run, but no such callable has been defined. Call scheduler.configure_task('test', func=...) to define the local callable.
|
...
When debugging, it turns out that the parameter passed here is actually None. This only happens as you pass a Task object to the scheduler. If you pass in the callable function directly, things work like a charm.
Your guidance / support is highly appreciated. Thanks a lot.
How can we reproduce the bug?
see above :)
The text was updated successfully, but these errors were encountered:
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.0a5post80
What happened?
We're using version 4.0.0a5.post80 of apscheduler and discovered an issue when configuring tasks on a scheduler passing a "Task" object. Basically, the Callable I'm passing is not stored as part of the Scheduler Task.
When debugging, it turns out that the parameter passed here is actually None. This only happens as you pass a Task object to the scheduler. If you pass in the callable function directly, things work like a charm.
Your guidance / support is highly appreciated. Thanks a lot.
How can we reproduce the bug?
see above :)
The text was updated successfully, but these errors were encountered: