i'm just learning asyncio and threads, so if someting is wrong, sorry
this is my code:
async def callback_onlyAlert(update: Update, context):
await update.message.reply_text('Ok! \nI will send you a message only when you can withdraw your USDN')
#run alert
t = threading.Thread(target=middleware_alert, args=(update, context,))
t.start()
def middleware_alert(update: Update,context):
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
loop.run_until_complete(alert(update, context))
loop.close()
async def alert(update: Update, context):
global block
global withdrawal_block
while True:
await update.message.reply_text("⚠️⚠️ -10 MINUTES! ⚠️⚠️")
time.sleep(20)
when i run it, i get got Future <Future pending> attached to a different loop
error, i know that asyncio make a loop for the main thread, and you can't pass object trough loops, so i think that's why i get this error
anyway i get update and context outside that loop, when app starts, so i can't create it after the loop starts, there is any turnaround? or i'm doing something wrong? thanks