【发布时间】:2023-01-26 15:41:48
【问题描述】:
我有这个 Telethon 代码:
from telethon import TelegramClient
import asyncio
api_id = ""
api_hash = ""
session = "john"
username = 'Hello_World' # For Example
async def main():
client = TelegramClient(session, api_id, api_hash)
await client.start()
entity = await client.get_entity("https://t.me/ahsan_alhadeeth")
search_user = await client.get_participants(entity, search=username)
print(search_user)
def in_channel():
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
loop.run_until_complete(main())
in_channel()
in_channel()
当我对in_channel() 进行一次调用时,它会正常运行直到完成。
但是当使用两个调用时它返回一个错误:sqlite3.OperationalError: database is locked。
我想知道如何在不进行多次会话的情况下多次使用同一个客户端。
请任何帮助。
【问题讨论】:
标签: python asynchronous client python-asyncio telethon