如果这是一个愚蠢的问题,我们深表歉意。
我是第一次尝试 telethon,它无法与我的电报 API 同步。
但是当我尝试连接以启动或连接客户端时收到此消息:
最后,当我尝试使用手机登录时出现 OperationalError: database is locked
错误。
完整的错误信息:
--------------------------------------------------------------------
OperationalError Traceback (most recent
call last)
<ipython-input-13-880bc0e4ea12> in <module>()
1 from telethon import TelegramClient, sync
----> 2 client = TelegramClient('session_name', api_id, api_hash)
3
4 client.connect()
5 if not client.is_user_authorized():
/anaconda3/lib/python3.7/site-
packages/telethon/client/telegrambaseclient.py in __init__(self,
session, api_id, api_hash, connection, use_ipv6, proxy, timeout,
request_retries, connection_retries, retry_delay, auto_reconnect,
sequential_updates, flood_sleep_threshold, device_model,
system_version, app_version, lang_code, system_lang_code, loop,
base_logger)
221 DEFAULT_DC_ID,
222 DEFAULT_IPV6_IP if self._use_ipv6 else
DEFAULT_IPV4_IP,
--> 223 DEFAULT_PORT
224 )
225
/anaconda3/lib/python3.7/site-packages/telethon/sessions/sqlite.py
in set_dc(self, dc_id, server_address, port)
184 def set_dc(self, dc_id, server_address, port):
185 super().set_dc(dc_id, server_address, port)
--> 186 self._update_session_table()
187
188 # Fetch the auth_key corresponding to this data center
/anaconda3/lib/python3.7/site-packages/telethon/sessions/sqlite.py
in _update_session_table(self)
205 # some more work before being able to save auth_key's
for
206 # multiple DCs. Probably done differently.
--> 207 c.execute('delete from sessions')
208 c.execute('insert or replace into sessions values
(?,?,?,?)', (
209 self._dc_id,
OperationalError: database is locked
协程对象 AuthMethods._start 是什么意思?为什么它给数据库锁定?
原文由 J.Doe 发布,翻译遵循 CC BY-SA 4.0 许可协议
参考 Telethon 文档,如果您没有正确关闭数据库,数据库将被锁定。
在您的情况下,您同时使用来自许多 TelegramClient 的相同
session
文件。第一的
TelegramClient 启动
第二
TelegramClient 已经激活
这也会导致
database is locked
错误。 更多信息: