Вот кусочек кода:
users_list_1hr = []
users_counter = 0
async def send_list(message: types.Message):
if message.from_user.username == ' un2' or message.from_user.username == 'un1':
await message.answer("Пользователи за последний час:")
for i in range(0, users_counter):
await message.answer(users_list_1hr[i])
async def schedule_refresher(message):
global users_counter, users_list_1hr
await send_list(message)
users_list_1hr.clear()
users_counter = 0
async def scheduler():
aioschedule.every().second.do(schedule_refresher(types.Message))
while True:
await aioschedule.run_pending()
await asyncio.sleep(1)
async def on_startup():
asyncio.create_task(scheduler())
последняя строка программы выглядит так:
if __name__ == '__main__':
executor.start_polling(dp, skip_updates=True, on_startup=on_startup)
При запуске кода выдает ошибку:
Task exception was never retrieved
future: <Task finished name='Task-6' coro=<scheduler() done, defined at C:\Users\Pavel\PycharmProjects\pythonProject2\main.py:52> exception=TypeError('the first argument must be callable')>
Traceback (most recent call last):
File "C:\Users\Pavel\PycharmProjects\pythonProject2\main.py", line 53, in scheduler
aioschedule.every().second.do(schedule_refresher(types.Message))
File "C:\Users\Pavel\PycharmProjects\pythonProject2\venv\lib\site-packages\aioschedule\__init__.py", line 436, in do
self.job_func = functools.partial(job_func, *args, **kwargs)
TypeError: the first argument must be callable
C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python39_64\lib\asyncio\base_events.py:1890: RuntimeWarning: coroutine 'schedule_refresher' was never awaited
handle = self._ready.popleft()
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Проблема явно в этом кусочке кода. Подскажите, пожалуйста, что я делаю не так?