P
P
pashak12020-10-06 18:41:17
Python
pashak1, 2020-10-06 18:41:17

I am writing a telegram bot on aiogram and the same error always crashes, how to fix it?

# start long polling

if  __name__ == '__main__':
    dp.loop.create_task(scheduled(10)) # пока что оставим 10 секунд (в качестве теста)
    executor.start_polling(dp, skip_updates=True).

gives such an error.
C:\Users\Simple\anaconda3\python.exe C:/Users/Simple/PycharmProjects/bot.py/bot.py
Traceback (most recent call last):
File "C:/Users/Simple/PycharmProjects/bot.py /bot.py", line 86, in
dp.loop.create_task(scheduled(10)) # leave 10 seconds for now (as a test)
AttributeError: 'NoneType' object has no attribute 'create_task'

Process finished with exit code 1

Answer the question

In order to leave comments, you need to log in

3 answer(s)
Z
zexer, 2020-10-06
@zexer

See what is returned in dp.loop, apparently there is None, but it is assumed that there should be a different object.

M
Maks, 2021-01-05
@MaksQ

loop = asyncio.get_event_loop()
loop.create_task(scheduled(10))

M
Mikhaillkin, 2020-10-10
@Mikhaillkin

I also faced the same problem. Did you manage to solve it?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question