-
Notifications
You must be signed in to change notification settings - Fork 723
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When using AsyncIOScheduler in version 3.11, decorators cannot be used. #1003
Comments
Please provide a minimal working example that demonstrates the issue. I'm not going to type the code from a screenshot. |
I don't think changing |
That change makes sure the scheduler does not create an event loop, period. Again, please provide a minimal working example so I can look at the issue. |
|
You're trying to add a job after you've closed the event loop. The asyncio scheduler can't work without a running event loop. |
This change actually has a change to the interface, which belongs to breaking chang, which will cause an error in the schedule_job decorator that took effect in the past. |
Your example doesn't even work on the previous release. |
The above example cannot be scheduled either. |
Even though you get no error from this on 3.10.4, it doesn't actually run either, for the reason I mentioned above. You need a running event loop in order to make the scheduler actually work. This is the reason I made this change: to explicitly fail when you're using the scheduler wrong. |
The following example works as expected: import asyncio
from apscheduler.schedulers.asyncio import AsyncIOScheduler
scheduler = AsyncIOScheduler()
@scheduler.scheduled_job("cron", second="*")
async def test():
print("test")
async def main():
scheduler.start()
await asyncio.sleep(float("inf"))
asyncio.run(main()) |
Thanks for the help, I should use |
No, you shouldn't. |
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
3.11
What happened?
When using AsyncIOScheduler in version 3.11, decorators cannot be used.
error message:runtimeerror event loop is closed
How can we reproduce the bug?
file1.py


file2.py
The text was updated successfully, but these errors were encountered: