Issue with run_pending() in python 3.11: Passing coroutines is forbidden, use tasks explicitly
- Dominant language
- Python
- Stars
- 12.3k
- Forks
- 999
- PR merge metrics
- No merged PRs in 30d
Description
Since upgrading to python 3.11, I had the following exception when run_pending() had a job to run:
```
Traceback (most recent call last):
File "C:\Code\Python\blabla\blabla.py", line 23, in run
await scheduler.run_pending()
File "C:\Program Files\Python311\Lib\site-packages\aioschedule\__init__.py", line 111, in run_pending
return await asyncio.wait(jobs, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\asyncio\tasks.py", line 415, in wait
raise TypeError("Passing coroutines is forbidden, use tasks explicitly.") TypeError: Passing coroutines is forbidden, use tasks explicitly.
```
I found this note in asyncio documentation: Deprecated since version 3.8, **will be removed in version 3.11: Passing coroutine objects to wait() directly is deprecated**.
https://docs.python.org/3/library/asyncio-task.html#asyncio.wait
So, it seems that:
`jobs = [job.run() for job in self.jobs if job.should_run]`
should become
`jobs = [asyncio.create_task(job.run()) for job in self.jobs if job.should_run]`
Thanks
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.