There is no current event loop in thread 'Thread-1'. Проблема при открытии сесcий telethon в нескольких потоках
В общем. Суть в том что мне надо запустить функцию, которая откроет 2 сесcии telethon. Даже при попытке ипользовать 1 поток выбивает ошибку:
There is no current event loop in thread 'Thread-1'.
There is no current event loop in thread 'Thread-2'.
import requests
from telethon import TelegramClient, sync
import sqlite3
import time
import threading
db = sqlite3.connect('Account.db')
cur = db.cursor()
cur.execute("SELECT max(ID) FROM Account")
accounts = int(cur.fetchone()[0])
acc = 1
def LTC(acc,api_id,api_hash):
print(1)
try:
session = str("anon" + str(acc))
client = TelegramClient(session, api_id, api_hash)
client.start()
print(14)
except Exception as e:
print(e)
pass
for i in range(1, accounts+1):
cur.execute(f"SELECT API_ID FROM Account WHERE ID = '{acc}'")
api_id = str(cur.fetchone()[0])
cur.execute(f"SELECT API_HASH FROM Account WHERE ID = '{acc}'")
api_hash = str(cur.fetchone()[0])
threading.Thread(target=LTC, args=(acc,api_id,api_hash,)).start()
acc = acc+1