Aioschedule не работает на windows. На MacOs все в полном порядке каждые 3 секунды смотрит на обновление на windows выдает ошибку

Рейтинг: 0Ответов: 0Опубликовано: 18.05.2023
# coding: cp1251
from aiogram import Bot, Dispatcher, executor, types 
from aiogram.dispatcher.filters import Text, StateFilter 
from aiogram.dispatcher import FSMContext 
from aiogram.dispatcher.filters.state import State, StatesGroup 
from aiogram.contrib.fsm_storage.memory import MemoryStorage 
from aiogram.utils.markdown import hbold 
import json 
import logging 
import time 
import hashlib 
import time
import aioschedule
import asyncio
import sqlite3
import
bot = Bot(token=token, parse_mode=types.ParseMode.HTML) 
storage = MemoryStorage() 
dp = Dispatcher(bot, storage=storage)  
logging.basicConfig(level=logging.INFO)   


class DataBase:
    def __init__(self,db_file):
        self.connect=sqlite3.connect(db_file)
        self.cursor=self.connect.cursor()

    async def add_users(self,user_id):
        with self.connect:
            return self.cursor.execute("""INSERT INTO users (user_id) VALUES (?)""",[user_id])

    async def get_users(self):
        with self.connect:
            return self.cursor.execute("""SELECT * FROM users""").fetchall()

    async def get_users1(self,user_id):
        with self.connect:
            return self.cursor.execute("""SELECT * FROM users WHERE user_id=(?)""",[user_id]).fetchall()

    async def get_hash_sum(self):
        with self.connect:
            return self.cursor.execute("""SELECT * FROM hash""").fetchall()

    async def update_hash_sum(self,hash_sum):
        with self.connect:
            return self.cursor.execute("""UPDATE hash SET hash_sum=(?)""",[hash_sum])


db=DataBase('db30.db')

async def noon_print():
    datauser=await db.get_users()
    hash_sum = await db.get_hash_sum()
    hash_sum=hash_sum[0][0]             
    with open("results.json","r", encoding="utf-8") as file:                     
        data = json.load(file)                 
    new_hash_sum = hashlib.md5(json.dumps(data).encode()).hexdigest()
      
    if new_hash_sum != hash_sum:                     
        hash_sum = new_hash_sum
        await db.update_hash_sum(hash_sum)
        for item in data:  
            for i in datauser:
                card = f"{hbold(item.get('result'))}"                         
                await bot.send_message(i[0],card)                         
                logging.info(f"Message sent to {i[0]}: {card}")
                time.sleep(0.2)
   
   
                  
              
    

async def scheduler():
    aioschedule.every(3).seconds.do(noon_print)
    while True:
        await aioschedule.run_pending()
        await asyncio.sleep(1)

async def on_startup(_):
    asyncio.create_task(scheduler())


@dp.message_handler(commands="start") 
async def start(message: types.Message):  
  
    start_buttons = ["***, ***, *** от 12%"]     
    keyboard = types.ReplyKeyboardMarkup(resize_keyboard=True)     
    keyboard.add(*start_buttons)      
    await message.answer("Индикатор Арбитражных событий", reply_markup=keyboard)     
  
@dp.message_handler(Text("***, ***, *** от 12%"))
async def get_arb(message: types.Message, state: FSMContext):     
    data=await db.get_users1(message.chat.id)
    if not data:
        await db.add_users(message.chat.id)
    await message.answer("Please waiting...")     
   
       
       




if __name__== 'main':     
    executor.start_polling(dp, skip_updates=False, on_startup=on_startup)

И сама ошибка 
    bot/TelegramBot.py
INFO:aiogram:Bot: Positivebet_signal_bot [@Positivebet_signal_bot]
INFO:aiogram.dispatcher.dispatcher:Start polling.
ERROR:asyncio:Task exception was never retrieved
future: <Task finished name='Task-4' coro=<scheduler() done, defined at c:\Users\Administrator\Desktop\Positivebot\TelegramBot.py:73> exception=TypeError('Passing coroutines is forbidden, use tasks explicitly.')>
Traceback (most recent call last):
  File "c:\Users\Administrator\Desktop\Positivebot\TelegramBot.py", line 76, in scheduler
    await aioschedule.run_pending()
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\aioschedule\__init__.py", line 544, in run_pending
    await default_scheduler.run_pending()
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\aioschedule\__init__.py", line 111, in run_pending
    return await asyncio.wait(jobs, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Administrator\AppData\Local\Programs\Python\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.
C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py:1923: RuntimeWarning: coroutine 'Job.run' was never
awaited
  handle = None  # Needed to break cycles when an exception occurs.
RuntimeWarning: Enable tracemalloc to get the object allocation traceback

Ответы

Ответов пока нет.