ail-project / ail-feeder-telegram

External telegram feeder for AIL framework
GNU Affero General Public License v3.0
13 stars 2 forks source link

Implement better error message when DB is locked #5

Open SteveClement opened 9 months ago

SteveClement commented 9 months ago

When the sqlite DB is locked, exit graciously (and earlier)

catch: sqlite3.OperationalError: database is locked

./feeder.py chats
Traceback (most recent call last):
  File "/home/ail/ail-feeder-telegram/bin/./feeder.py", line 138, in <module>
    tg.connect()
  File "/home/ail/ail-feeder-telegram/bin/telegram.py", line 93, in connect
    self.client.start()
  File "/home/ail/ail-feeder-telegram/venv/lib/python3.11/site-packages/telethon/client/auth.py", line 128, in start
    else self.loop.run_until_complete(coro)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/home/ail/ail-feeder-telegram/venv/lib/python3.11/site-packages/telethon/client/auth.py", line 135, in _start
    await self.connect()
  File "/home/ail/ail-feeder-telegram/venv/lib/python3.11/site-packages/telethon/client/telegrambaseclient.py", line 555, in onnect
    self.session.auth_key = self._sender.auth_key
    ^^^^^^^^^^^^^^^^^^^^^
  File "/home/ail/ail-feeder-telegram/venv/lib/python3.11/site-packages/telethon/sessions/sqlite.py", line 180, in auth_key
    self._update_session_table()
  File "/home/ail/ail-feeder-telegram/venv/lib/python3.11/site-packages/telethon/sessions/sqlite.py", line 194, in _update_session_table
    c.execute('delete from sessions')
sqlite3.OperationalError: database is locked
Task was destroyed but it is pending!
task: <Task pending name='Task-3' coro=<Connection._send_loop() running at /home/ail/ail-feeder-telegram/venv/lib/python3.11/site-packages/telethon/network/connection/connection.py:316> wait_for=<Future pending cb=[Task.task_wakeup()]>>
Task was destroyed but it is pending!
task: <Task pending name='Task-4' coro=<Connection._recv_loop() running at /home/ail/ail-feeder-telegram/venv/lib/python3.11/site-packages/telethon/network/connection/connection.py:335> wait_for=<Future pending cb=[Task.task_wakeup()]>>
Task was destroyed but it is pending!
task: <Task pending name='Task-5' coro=<MTProtoSender._send_loop() running at /home/ail/ail-feeder-telegram/venv/lib/python3.11/site-packages/telethon/network/mtprotosender.py:464> wait_for=<Future pending cb=[Task.task_wakeup()]>>
Task was destroyed but it is pending!
task: <Task pending name='Task-6' coro=<MTProtoSender._recv_loop() running at /home/ail/ail-feeder-telegram/venv/lib/python3.11/site-packages/telethon/network/mtprotosender.py:507> wait_for=<Future pending cb=[Task.task_wakeup()]>>
Exception ignored in: <coroutine object Connection._recv_loop at 0x7326305854e0>
RuntimeError: coroutine ignored GeneratorExit