Removing the “Passing coroutines is forbidden, use tasks explicitly” error when using aioschedule in Python 3.11

In Python, the aioschedule library is often used to execute tasks at certain intervals, for example, when developing Telegram bots.

Unfortunately, the aioschedule package has not been updated for several years and has lost compatibility with the latest versions of Python. When used in Python 3.11, an error is thrown at the time of tasks execution

Passing coroutines is forbidden, use tasks explicitly.

Solutions

1. Migrate to another scheduler – another package that allows perform operations at the desired time intervals.

Alternatively, this can be, for example, the apscheduler package.

2. Make changes to your local copy of the aioschedule package.

Find on your local computer where the aioschedule package is installed. This can be a shared “site-packages” directory with packages for all users of the operating system, or a “site-packages” directory in the local virtual environment of a particular project that uses aioschedule.

In the “aioschedule” subdirectory, open the __init__.py file for editing.

On line 107, replace

with

and save changes.

Now the aioschedule tasks in your project will run correctly and the error “Passing coroutines is forbidden, use tasks explicitly.” will not appear.

5 1 vote
Article Rating
Subscribe
Notify of
0 Комментарий
Newest
Oldest Most Voted
Inline Feedbacks
View all comments