2026-09-28 17:35:48,117 INFO core: Event loop thread started, running loop forever
2026-09-28 17:35:48,418 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-28 17:35:48,427 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 17:40:44,948 INFO core: _init_accounts coroutine started
2026-09-28 17:40:44,950 INFO core: _init_accounts_inner: starting DB migrations
2026-09-28 17:40:44,955 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 17:45:23,116 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 17:50:17,960 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-28 17:50:17,960 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-28 17:50:17,960 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 17:55:17,537 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 18:00:05,441 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-28 18:00:05,460 INFO core: _init_accounts_inner: reloading LLM config
2026-09-28 18:00:05,460 WARNING core: LLM config load failed: cannot schedule new futures after shutdown
2026-09-28 18:00:05,461 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-09-28 18:00:05,461 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 180, in _init_accounts_inner
    await self._start_account_client(acct["id"])
  File "/home/wovewbge/quill.nx.kg/core.py", line 236, in _start_account_client
    session_str = await self._run_db(self.db.get_account_session, account_id)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-09-28 18:00:39,137 INFO core: Event loop thread started, running loop forever
2026-09-28 18:00:39,438 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-28 18:00:39,443 INFO core: _init_accounts coroutine started
2026-09-28 18:00:39,443 INFO core: _init_accounts_inner: starting DB migrations
2026-09-28 18:00:39,447 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 18:05:34,984 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 18:10:34,008 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-28 18:10:34,009 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-28 18:10:34,035 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 18:15:07,394 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-28 18:15:07,401 INFO core: _init_accounts_inner: reloading LLM config
2026-09-28 18:15:07,406 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 18:20:14,418 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-09-28 18:20:14,418 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-09-28 18:20:14,419 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 180, in _init_accounts_inner
    await self._start_account_client(acct["id"])
  File "/home/wovewbge/quill.nx.kg/core.py", line 236, in _start_account_client
    session_str = await self._run_db(self.db.get_account_session, account_id)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-09-28 18:20:34,042 INFO core: Event loop thread started, running loop forever
2026-09-28 18:20:34,343 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-28 18:20:34,347 INFO core: _init_accounts coroutine started
2026-09-28 18:20:34,348 INFO core: _init_accounts_inner: starting DB migrations
2026-09-28 18:20:34,357 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-28 18:20:34,358 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-28 18:20:34,358 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-28 18:20:34,360 INFO core: _init_accounts_inner: reloading LLM config
2026-09-28 18:20:34,375 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-09-28 18:20:34,375 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 18:20:34,375 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-09-28 18:25:10,754 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 18:30:17,412 INFO core: Account 2: connecting to Telegram via 91.108.56.178...
2026-09-28 18:30:41,090 INFO core: Event loop thread started, running loop forever
2026-09-28 18:30:41,400 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-28 18:30:41,404 INFO core: _init_accounts coroutine started
2026-09-28 18:30:41,405 INFO core: _init_accounts_inner: starting DB migrations
2026-09-28 18:30:41,411 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 18:35:10,224 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 18:40:47,210 INFO core: Event loop thread started, running loop forever
2026-09-28 18:40:47,511 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-28 18:40:47,514 INFO core: _init_accounts coroutine started
2026-09-28 18:40:47,516 INFO core: _init_accounts_inner: starting DB migrations
2026-09-28 18:40:47,522 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 18:45:49,568 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 126, in _init_accounts_inner
    accounts = await self._run_db(self.db.get_accounts)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 540, in get_accounts
    with self._conn() as conn:
         ~~~~~~~~~~^^
  File "/opt/alt/python313/lib64/python3.13/contextlib.py", line 141, in __enter__
    return next(self.gen)
  File "/home/wovewbge/quill.nx.kg/db.py", line 59, in _conn
    conn = _pool.connect()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 448, in connect
    return _ConnectionFairy._checkout(self)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 1272, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 712, in checkout
    rec = pool._do_get()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/impl.py", line 178, in _do_get
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/impl.py", line 176, in _do_get
    return self._create_connection()
           ~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection
    return _ConnectionRecord(self)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 674, in __init__
    self.__connect()
    ~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 900, in __connect
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 896, in __connect
    self.dbapi_connection = connection = pool._invoke_creator(self)
                                         ~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 361, in <lambda>
    return lambda rec: creator_fn()
                       ~~~~~~~~~~^^
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-09-28 18:45:49,575 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 18:50:35,966 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 18:55:51,941 INFO core: Event loop thread started, running loop forever
2026-09-28 18:55:52,242 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-28 18:55:52,245 INFO core: _init_accounts coroutine started
2026-09-28 18:55:52,245 INFO core: _init_accounts_inner: starting DB migrations
2026-09-28 18:55:52,259 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 19:00:25,591 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 19:05:32,423 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-28 19:05:32,424 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-28 19:05:32,424 WARNING core: ensure_llm_schema failed: cannot schedule new futures after shutdown
2026-09-28 19:05:32,425 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-28 19:05:32,425 WARNING core: ensure_pair_schema failed: cannot schedule new futures after shutdown
2026-09-28 19:05:32,426 INFO core: _init_accounts_inner: reloading LLM config
2026-09-28 19:05:32,426 WARNING core: LLM config load failed: cannot schedule new futures after shutdown
2026-09-28 19:05:32,426 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-09-28 19:05:36,950 INFO core: Event loop thread started, running loop forever
2026-09-28 19:05:37,252 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-28 19:05:37,255 INFO core: _init_accounts coroutine started
2026-09-28 19:05:37,257 INFO core: _init_accounts_inner: starting DB migrations
2026-09-28 19:05:37,262 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 19:10:19,597 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 19:15:25,000 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-28 19:15:25,000 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-28 19:15:25,003 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-28 19:15:25,020 INFO core: _init_accounts_inner: reloading LLM config
2026-09-28 19:15:25,027 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 19:20:06,179 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 19:25:12,974 INFO core: Event loop thread started, running loop forever
2026-09-28 19:25:13,275 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-28 19:25:13,279 INFO core: _init_accounts coroutine started
2026-09-28 19:25:13,281 INFO core: _init_accounts_inner: starting DB migrations
2026-09-28 19:25:13,295 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 19:30:21,474 INFO core: Event loop thread started, running loop forever
2026-09-28 19:30:21,779 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-28 19:30:21,785 INFO core: _init_accounts coroutine started
2026-09-28 19:30:21,785 INFO core: _init_accounts_inner: starting DB migrations
2026-09-28 19:30:21,793 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 19:35:28,444 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-09-28 19:35:45,035 INFO core: Event loop thread started, running loop forever
2026-09-28 19:35:45,336 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-28 19:35:45,348 INFO core: _init_accounts coroutine started
2026-09-28 19:35:45,348 INFO core: _init_accounts_inner: starting DB migrations
2026-09-28 19:35:45,352 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 19:40:25,132 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 19:40:25,132 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-28 19:40:25,133 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-28 19:45:32,408 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-28 19:45:32,409 WARNING core: ensure_pair_schema failed: cannot schedule new futures after shutdown
2026-09-28 19:45:32,410 INFO core: _init_accounts_inner: reloading LLM config
2026-09-28 19:45:32,410 WARNING core: LLM config load failed: cannot schedule new futures after shutdown
2026-09-28 19:45:32,410 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-09-28 19:45:33,222 INFO core: Event loop thread started, running loop forever
2026-09-28 19:45:33,523 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-28 19:45:33,526 INFO core: _init_accounts coroutine started
2026-09-28 19:45:33,527 INFO core: _init_accounts_inner: starting DB migrations
2026-09-28 19:45:33,536 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 19:45:33,537 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-28 19:45:33,538 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-28 19:50:32,766 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-28 19:50:32,767 INFO core: _init_accounts_inner: reloading LLM config
2026-09-28 19:50:32,778 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-09-28 19:50:32,778 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-09-28 19:50:32,783 INFO core: Account 2: connecting to Telegram via 91.108.56.178...
2026-09-28 19:50:32,784 INFO telethon.network.mtprotosender: Connecting to 91.108.56.178:443/TcpAbridged...
2026-09-28 19:50:32,790 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 19:55:03,050 WARNING telethon.network.mtprotosender: Attempt 1 at connecting failed: TimeoutError: 
2026-09-28 19:55:03,052 WARNING core: Account 2: connect timed out after 35s
2026-09-28 19:55:03,053 INFO telethon.network.mtprotosender: Disconnecting from 91.108.56.178:443/TcpAbridged...
2026-09-28 19:55:03,053 INFO telethon.network.mtprotosender: Disconnection from 91.108.56.178:443/TcpAbridged complete!
2026-09-28 19:55:03,054 INFO telethon.network.mtprotosender: Not disconnecting (already have no connection)
2026-09-28 19:55:03,055 INFO core: Account 2: connecting to Telegram via 91.108.56.181...
2026-09-28 19:55:03,055 INFO telethon.network.mtprotosender: Connecting to 91.108.56.181:443/TcpAbridged...
2026-09-28 19:55:03,103 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 20:00:39,361 INFO core: Event loop thread started, running loop forever
2026-09-28 20:00:39,662 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-28 20:00:39,666 INFO core: _init_accounts coroutine started
2026-09-28 20:00:39,667 INFO core: _init_accounts_inner: starting DB migrations
2026-09-28 20:00:39,673 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 20:05:21,351 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-09-28 20:05:21,362 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 20:10:50,121 INFO core: Event loop thread started, running loop forever
2026-09-28 20:10:50,422 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-28 20:10:50,427 INFO core: _init_accounts coroutine started
2026-09-28 20:10:50,427 INFO core: _init_accounts_inner: starting DB migrations
2026-09-28 20:10:50,432 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 20:15:48,208 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 20:20:09,239 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 20:20:09,241 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-28 20:25:10,305 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-28 20:25:10,310 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-28 20:25:10,310 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 20:30:30,436 INFO core: Event loop thread started, running loop forever
2026-09-28 20:30:30,737 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-28 20:30:30,741 INFO core: _init_accounts coroutine started
2026-09-28 20:30:30,742 INFO core: _init_accounts_inner: starting DB migrations
2026-09-28 20:30:30,756 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-28 20:30:30,756 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-28 20:30:30,763 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 20:30:30,764 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-28 20:35:37,524 INFO core: _init_accounts_inner: reloading LLM config
2026-09-28 20:35:37,525 WARNING core: LLM config load failed: cannot schedule new futures after shutdown
2026-09-28 20:35:37,525 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-09-28 20:35:49,416 INFO core: Event loop thread started, running loop forever
2026-09-28 20:35:49,717 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-28 20:35:49,723 INFO core: _init_accounts coroutine started
2026-09-28 20:35:49,723 INFO core: _init_accounts_inner: starting DB migrations
2026-09-28 20:35:49,729 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 20:40:39,877 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 20:45:41,788 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-09-28 20:45:41,796 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 20:50:42,855 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 20:55:48,958 INFO core: Event loop thread started, running loop forever
2026-09-28 20:55:49,259 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-28 20:55:49,264 INFO core: _init_accounts coroutine started
2026-09-28 20:55:49,267 INFO core: _init_accounts_inner: starting DB migrations
2026-09-28 20:55:49,273 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 21:00:50,133 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-28 21:00:50,133 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-28 21:00:50,135 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-28 21:00:50,136 INFO core: _init_accounts_inner: reloading LLM config
2026-09-28 21:00:50,145 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 21:05:10,435 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-09-28 21:05:10,436 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-09-28 21:05:10,442 INFO core: Account 2: connecting to Telegram via 91.108.56.178...
2026-09-28 21:05:10,444 INFO telethon.network.mtprotosender: Connecting to 91.108.56.178:443/TcpAbridged...
2026-09-28 21:05:10,451 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 21:10:17,399 WARNING telethon.network.mtprotosender: Attempt 1 at connecting failed: TimeoutError: 
2026-09-28 21:10:17,400 WARNING core: Account 2: connect timed out after 35s
2026-09-28 21:10:17,401 INFO telethon.network.mtprotosender: Disconnecting from 91.108.56.178:443/TcpAbridged...
2026-09-28 21:10:17,401 INFO telethon.network.mtprotosender: Disconnection from 91.108.56.178:443/TcpAbridged complete!
2026-09-28 21:10:17,402 INFO telethon.network.mtprotosender: Not disconnecting (already have no connection)
2026-09-28 21:10:17,403 INFO core: Account 2: connecting to Telegram via 91.108.56.181...
2026-09-28 21:10:17,403 INFO telethon.network.mtprotosender: Connecting to 91.108.56.181:443/TcpAbridged...
2026-09-28 21:10:38,116 INFO core: Event loop thread started, running loop forever
2026-09-28 21:10:38,418 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-28 21:10:38,427 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 21:15:06,284 INFO core: _init_accounts coroutine started
2026-09-28 21:15:06,284 INFO core: _init_accounts_inner: starting DB migrations
2026-09-28 21:15:06,290 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 21:20:45,478 INFO core: Event loop thread started, running loop forever
2026-09-28 21:20:45,779 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-28 21:20:45,786 INFO core: _init_accounts coroutine started
2026-09-28 21:20:45,787 INFO core: _init_accounts_inner: starting DB migrations
2026-09-28 21:20:45,791 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 21:25:52,420 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-09-28 21:25:52,976 INFO core: Event loop thread started, running loop forever
2026-09-28 21:25:53,277 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-28 21:25:53,282 INFO core: _init_accounts coroutine started
2026-09-28 21:25:53,284 INFO core: _init_accounts_inner: starting DB migrations
2026-09-28 21:25:53,291 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 21:30:48,875 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 21:35:07,663 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-28 21:35:07,664 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-28 21:35:07,671 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-28 21:35:07,675 INFO core: _init_accounts_inner: reloading LLM config
2026-09-28 21:35:07,681 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 21:40:13,519 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-09-28 21:40:13,519 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-09-28 21:40:13,520 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 180, in _init_accounts_inner
    await self._start_account_client(acct["id"])
  File "/home/wovewbge/quill.nx.kg/core.py", line 236, in _start_account_client
    session_str = await self._run_db(self.db.get_account_session, account_id)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-09-28 21:40:25,402 INFO core: Event loop thread started, running loop forever
2026-09-28 21:40:25,703 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-28 21:40:25,707 INFO core: _init_accounts coroutine started
2026-09-28 21:40:25,713 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 21:40:25,730 INFO core: _init_accounts_inner: starting DB migrations
2026-09-28 21:45:53,263 INFO core: Event loop thread started, running loop forever
2026-09-28 21:45:53,564 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-28 21:45:53,568 INFO core: _init_accounts coroutine started
2026-09-28 21:45:53,568 INFO core: _init_accounts_inner: starting DB migrations
2026-09-28 21:45:53,575 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 21:50:06,168 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-28 21:50:06,169 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-28 21:50:06,172 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-28 21:50:06,173 INFO core: _init_accounts_inner: reloading LLM config
2026-09-28 21:50:06,176 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 21:55:46,731 INFO core: Event loop thread started, running loop forever
2026-09-28 21:55:47,033 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-28 21:55:47,037 INFO core: _init_accounts coroutine started
2026-09-28 21:55:47,039 INFO core: _init_accounts_inner: starting DB migrations
2026-09-28 21:55:47,048 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 22:00:32,623 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-09-28 22:00:32,634 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 22:05:04,596 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 22:10:15,026 INFO core: Event loop thread started, running loop forever
2026-09-28 22:10:15,327 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-28 22:10:15,332 INFO core: _init_accounts coroutine started
2026-09-28 22:10:15,337 INFO core: _init_accounts_inner: starting DB migrations
2026-09-28 22:10:15,338 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 22:15:09,702 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 22:20:35,410 INFO core: Event loop thread started, running loop forever
2026-09-28 22:20:35,711 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-28 22:20:35,714 INFO core: _init_accounts coroutine started
2026-09-28 22:20:35,715 INFO core: _init_accounts_inner: starting DB migrations
2026-09-28 22:20:35,722 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 22:25:51,426 INFO core: Event loop thread started, running loop forever
2026-09-28 22:25:51,727 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-28 22:25:51,731 INFO core: _init_accounts coroutine started
2026-09-28 22:25:51,733 INFO core: _init_accounts_inner: starting DB migrations
2026-09-28 22:25:51,738 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 22:30:39,414 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-28 22:30:39,414 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-28 22:30:39,415 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-28 22:30:39,417 INFO core: _init_accounts_inner: reloading LLM config
2026-09-28 22:30:39,431 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 22:30:39,432 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-09-28 22:30:39,432 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-09-28 22:35:18,629 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 22:40:24,416 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 180, in _init_accounts_inner
    await self._start_account_client(acct["id"])
  File "/home/wovewbge/quill.nx.kg/core.py", line 236, in _start_account_client
    session_str = await self._run_db(self.db.get_account_session, account_id)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 562, in get_account_session
    with self._conn() as conn:
         ~~~~~~~~~~^^
  File "/opt/alt/python313/lib64/python3.13/contextlib.py", line 141, in __enter__
    return next(self.gen)
  File "/home/wovewbge/quill.nx.kg/db.py", line 59, in _conn
    conn = _pool.connect()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 448, in connect
    return _ConnectionFairy._checkout(self)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 1272, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 717, in checkout
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 715, in checkout
    dbapi_connection = rec.get_connection()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 866, in get_connection
    self.__connect()
    ~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 900, in __connect
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 896, in __connect
    self.dbapi_connection = connection = pool._invoke_creator(self)
                                         ~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 361, in <lambda>
    return lambda rec: creator_fn()
                       ~~~~~~~~~~^^
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-09-28 22:40:39,689 INFO core: Event loop thread started, running loop forever
2026-09-28 22:40:39,991 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-28 22:40:39,994 INFO core: _init_accounts coroutine started
2026-09-28 22:40:39,996 INFO core: _init_accounts_inner: starting DB migrations
2026-09-28 22:40:40,000 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 22:45:51,579 INFO core: Event loop thread started, running loop forever
2026-09-28 22:45:51,881 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-28 22:45:51,884 INFO core: _init_accounts coroutine started
2026-09-28 22:45:51,885 INFO core: _init_accounts_inner: starting DB migrations
2026-09-28 22:45:51,897 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 22:50:52,956 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 22:55:29,105 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-28 22:55:29,106 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-28 22:55:29,113 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-28 22:55:29,115 INFO core: _init_accounts_inner: reloading LLM config
2026-09-28 22:55:29,117 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 23:00:21,729 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 23:05:04,576 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 23:10:11,494 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-09-28 23:10:11,495 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-09-28 23:10:11,495 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 180, in _init_accounts_inner
    await self._start_account_client(acct["id"])
  File "/home/wovewbge/quill.nx.kg/core.py", line 236, in _start_account_client
    session_str = await self._run_db(self.db.get_account_session, account_id)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-09-28 23:10:34,175 INFO core: Event loop thread started, running loop forever
2026-09-28 23:10:34,476 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-28 23:10:34,480 INFO core: _init_accounts coroutine started
2026-09-28 23:10:34,482 INFO core: _init_accounts_inner: starting DB migrations
2026-09-28 23:10:34,487 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 23:15:38,311 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 23:15:38,316 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-28 23:20:07,053 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-28 23:20:07,060 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 23:25:31,789 INFO core: Event loop thread started, running loop forever
2026-09-28 23:25:32,090 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-28 23:25:32,093 INFO core: _init_accounts coroutine started
2026-09-28 23:25:32,094 INFO core: _init_accounts_inner: starting DB migrations
2026-09-28 23:25:32,103 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 23:30:05,180 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-09-28 23:30:05,230 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 23:35:22,157 INFO core: Event loop thread started, running loop forever
2026-09-28 23:35:22,458 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-28 23:35:22,462 INFO core: _init_accounts coroutine started
2026-09-28 23:35:22,465 INFO core: _init_accounts_inner: starting DB migrations
2026-09-28 23:35:22,475 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 23:40:23,943 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-28 23:40:23,944 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-28 23:40:23,946 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-28 23:40:23,951 INFO core: _init_accounts_inner: reloading LLM config
2026-09-28 23:40:23,951 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 23:45:29,456 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-09-28 23:45:31,779 INFO core: Event loop thread started, running loop forever
2026-09-28 23:45:32,080 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-28 23:45:32,085 INFO core: _init_accounts coroutine started
2026-09-28 23:45:32,085 INFO core: _init_accounts_inner: starting DB migrations
2026-09-28 23:45:32,092 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 23:50:25,346 INFO core: status() clients=0 connected=False forwarding=False
2026-09-28 23:55:32,294 INFO core: Event loop thread started, running loop forever
2026-09-28 23:55:32,595 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-28 23:55:32,598 INFO core: _init_accounts coroutine started
2026-09-28 23:55:32,600 INFO core: _init_accounts_inner: starting DB migrations
2026-09-28 23:55:32,615 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 00:00:37,768 INFO core: Event loop thread started, running loop forever
2026-09-29 00:00:38,069 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 00:00:38,072 INFO core: _init_accounts coroutine started
2026-09-29 00:00:38,073 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 00:00:38,077 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 00:05:47,745 INFO core: Event loop thread started, running loop forever
2026-09-29 00:05:48,045 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 00:05:48,052 INFO core: _init_accounts coroutine started
2026-09-29 00:05:48,055 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 00:05:48,083 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 00:10:33,824 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-29 00:10:33,825 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-29 00:10:33,832 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-29 00:10:33,833 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 00:15:06,241 INFO core: _init_accounts_inner: reloading LLM config
2026-09-29 00:15:06,283 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 00:20:48,703 INFO core: Event loop thread started, running loop forever
2026-09-29 00:20:49,004 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 00:20:49,014 INFO core: _init_accounts coroutine started
2026-09-29 00:20:49,014 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 00:20:49,028 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 00:25:40,050 INFO core: Event loop thread started, running loop forever
2026-09-29 00:25:40,352 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 00:25:40,355 INFO core: _init_accounts coroutine started
2026-09-29 00:25:40,356 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 00:25:40,365 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 00:30:49,143 INFO core: Event loop thread started, running loop forever
2026-09-29 00:30:49,444 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 00:30:49,449 INFO core: _init_accounts coroutine started
2026-09-29 00:30:49,450 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 00:30:49,461 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 00:35:42,176 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 00:40:08,463 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 126, in _init_accounts_inner
    accounts = await self._run_db(self.db.get_accounts)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 540, in get_accounts
    with self._conn() as conn:
         ~~~~~~~~~~^^
  File "/opt/alt/python313/lib64/python3.13/contextlib.py", line 141, in __enter__
    return next(self.gen)
  File "/home/wovewbge/quill.nx.kg/db.py", line 59, in _conn
    conn = _pool.connect()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 448, in connect
    return _ConnectionFairy._checkout(self)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 1272, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 717, in checkout
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 715, in checkout
    dbapi_connection = rec.get_connection()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 866, in get_connection
    self.__connect()
    ~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 900, in __connect
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 896, in __connect
    self.dbapi_connection = connection = pool._invoke_creator(self)
                                         ~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 361, in <lambda>
    return lambda rec: creator_fn()
                       ~~~~~~~~~~^^
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-09-29 00:40:08,475 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 00:45:04,648 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 00:50:24,814 INFO core: Event loop thread started, running loop forever
2026-09-29 00:50:25,115 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 00:50:25,118 INFO core: _init_accounts coroutine started
2026-09-29 00:50:25,121 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 00:50:25,130 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 00:55:31,430 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 149, in _init_accounts_inner
    await self._run_db(self.db.migrate_legacy_session)
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-09-29 00:55:33,757 INFO core: Event loop thread started, running loop forever
2026-09-29 00:55:34,059 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 00:55:34,063 INFO core: _init_accounts coroutine started
2026-09-29 00:55:34,066 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 00:55:34,069 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 01:00:06,282 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 01:05:05,853 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 126, in _init_accounts_inner
    accounts = await self._run_db(self.db.get_accounts)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 540, in get_accounts
    with self._conn() as conn:
         ~~~~~~~~~~^^
  File "/opt/alt/python313/lib64/python3.13/contextlib.py", line 141, in __enter__
    return next(self.gen)
  File "/home/wovewbge/quill.nx.kg/db.py", line 59, in _conn
    conn = _pool.connect()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 448, in connect
    return _ConnectionFairy._checkout(self)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 1272, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 717, in checkout
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 715, in checkout
    dbapi_connection = rec.get_connection()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 866, in get_connection
    self.__connect()
    ~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 900, in __connect
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 896, in __connect
    self.dbapi_connection = connection = pool._invoke_creator(self)
                                         ~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 361, in <lambda>
    return lambda rec: creator_fn()
                       ~~~~~~~~~~^^
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-09-29 01:05:05,870 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 01:10:06,444 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 01:15:44,530 INFO core: Event loop thread started, running loop forever
2026-09-29 01:15:44,831 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 01:15:44,835 INFO core: _init_accounts coroutine started
2026-09-29 01:15:44,837 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 01:15:44,844 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 01:20:21,911 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 01:25:27,430 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 149, in _init_accounts_inner
    await self._run_db(self.db.migrate_legacy_session)
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-09-29 01:25:43,715 INFO core: Event loop thread started, running loop forever
2026-09-29 01:25:44,017 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 01:25:44,027 INFO core: _init_accounts coroutine started
2026-09-29 01:25:44,027 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 01:25:44,028 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 01:30:19,383 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-29 01:30:19,384 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-29 01:30:19,385 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-29 01:30:19,387 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 01:35:26,478 INFO core: _init_accounts_inner: reloading LLM config
2026-09-29 01:35:26,478 WARNING core: LLM config load failed: cannot schedule new futures after shutdown
2026-09-29 01:35:26,479 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-09-29 01:35:26,479 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 180, in _init_accounts_inner
    await self._start_account_client(acct["id"])
  File "/home/wovewbge/quill.nx.kg/core.py", line 236, in _start_account_client
    session_str = await self._run_db(self.db.get_account_session, account_id)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-09-29 01:35:48,283 INFO core: Event loop thread started, running loop forever
2026-09-29 01:35:48,584 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 01:35:48,591 INFO core: _init_accounts coroutine started
2026-09-29 01:35:48,594 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 01:35:48,614 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 01:40:29,246 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 01:45:48,542 INFO core: Event loop thread started, running loop forever
2026-09-29 01:45:48,843 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 01:45:48,852 INFO core: _init_accounts coroutine started
2026-09-29 01:45:48,853 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 01:45:48,857 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 01:50:19,789 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 126, in _init_accounts_inner
    accounts = await self._run_db(self.db.get_accounts)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 540, in get_accounts
    with self._conn() as conn:
         ~~~~~~~~~~^^
  File "/opt/alt/python313/lib64/python3.13/contextlib.py", line 141, in __enter__
    return next(self.gen)
  File "/home/wovewbge/quill.nx.kg/db.py", line 59, in _conn
    conn = _pool.connect()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 448, in connect
    return _ConnectionFairy._checkout(self)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 1272, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 712, in checkout
    rec = pool._do_get()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/impl.py", line 178, in _do_get
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/impl.py", line 176, in _do_get
    return self._create_connection()
           ~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection
    return _ConnectionRecord(self)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 674, in __init__
    self.__connect()
    ~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 900, in __connect
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 896, in __connect
    self.dbapi_connection = connection = pool._invoke_creator(self)
                                         ~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 361, in <lambda>
    return lambda rec: creator_fn()
                       ~~~~~~~~~~^^
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-09-29 01:50:19,805 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 01:55:16,746 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 02:00:30,444 INFO core: Event loop thread started, running loop forever
2026-09-29 02:00:30,746 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 02:00:30,752 INFO core: _init_accounts coroutine started
2026-09-29 02:00:30,753 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 02:00:30,781 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 02:05:21,826 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 02:10:06,911 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 02:15:05,417 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-29 02:15:05,418 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-29 02:15:05,466 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-29 02:15:05,467 WARNING core: ensure_pair_schema failed: cannot schedule new futures after shutdown
2026-09-29 02:15:42,806 INFO core: Event loop thread started, running loop forever
2026-09-29 02:15:43,107 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 02:15:43,112 INFO core: _init_accounts coroutine started
2026-09-29 02:15:43,112 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 02:15:43,129 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 02:20:28,070 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 02:25:14,586 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-29 02:25:14,589 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-29 02:25:14,590 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 02:30:21,461 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-29 02:30:23,923 INFO core: Event loop thread started, running loop forever
2026-09-29 02:30:24,224 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 02:30:24,239 INFO core: _init_accounts coroutine started
2026-09-29 02:30:24,239 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 02:30:24,268 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-29 02:30:24,268 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-29 02:30:24,271 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 02:35:26,362 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 02:40:15,720 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-29 02:40:15,726 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 02:40:15,729 INFO core: _init_accounts_inner: reloading LLM config
2026-09-29 02:45:21,477 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-09-29 02:45:21,478 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-09-29 02:45:21,478 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 180, in _init_accounts_inner
    await self._start_account_client(acct["id"])
  File "/home/wovewbge/quill.nx.kg/core.py", line 236, in _start_account_client
    session_str = await self._run_db(self.db.get_account_session, account_id)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-09-29 02:45:26,647 INFO core: Event loop thread started, running loop forever
2026-09-29 02:45:26,948 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 02:45:26,953 INFO core: _init_accounts coroutine started
2026-09-29 02:45:26,954 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 02:45:26,965 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 02:50:19,901 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-09-29 02:50:19,933 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 02:55:16,711 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 03:00:33,013 INFO core: Event loop thread started, running loop forever
2026-09-29 03:00:33,315 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 03:00:33,326 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 03:05:10,723 INFO core: _init_accounts coroutine started
2026-09-29 03:05:10,724 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 03:05:10,736 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 03:10:16,914 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 149, in _init_accounts_inner
    await self._run_db(self.db.migrate_legacy_session)
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-09-29 03:10:47,528 INFO core: Event loop thread started, running loop forever
2026-09-29 03:10:47,829 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 03:10:47,832 INFO core: _init_accounts coroutine started
2026-09-29 03:10:47,834 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 03:10:47,841 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 03:15:14,246 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 03:20:45,800 INFO core: Event loop thread started, running loop forever
2026-09-29 03:20:46,101 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 03:20:46,109 INFO core: _init_accounts coroutine started
2026-09-29 03:20:46,109 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 03:20:46,122 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-29 03:20:46,122 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-29 03:20:46,122 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 03:25:04,124 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-29 03:25:04,149 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 03:25:04,150 INFO core: _init_accounts_inner: reloading LLM config
2026-09-29 03:30:49,935 INFO core: Event loop thread started, running loop forever
2026-09-29 03:30:50,236 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 03:30:50,239 INFO core: _init_accounts coroutine started
2026-09-29 03:30:50,241 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 03:30:50,246 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 03:35:32,446 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-09-29 03:35:32,456 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 03:40:50,896 INFO core: Event loop thread started, running loop forever
2026-09-29 03:40:51,197 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 03:40:51,205 INFO core: _init_accounts coroutine started
2026-09-29 03:40:51,205 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 03:40:51,208 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 03:45:41,971 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 03:50:35,807 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-29 03:50:35,808 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-29 03:50:35,808 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 03:55:16,539 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-29 03:55:16,545 INFO core: _init_accounts_inner: reloading LLM config
2026-09-29 03:55:16,562 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 03:55:16,563 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-09-29 03:55:16,563 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-09-29 04:00:17,857 INFO core: Account 2: connecting to Telegram via 91.108.56.178...
2026-09-29 04:00:17,859 INFO telethon.network.mtprotosender: Connecting to 91.108.56.178:443/TcpAbridged...
2026-09-29 04:00:17,882 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 04:05:05,452 WARNING telethon.network.mtprotosender: Attempt 1 at connecting failed: TimeoutError: 
2026-09-29 04:05:05,452 WARNING core: Account 2: connect timed out after 35s
2026-09-29 04:05:05,453 INFO telethon.network.mtprotosender: Disconnecting from 91.108.56.178:443/TcpAbridged...
2026-09-29 04:05:05,453 INFO telethon.network.mtprotosender: Disconnection from 91.108.56.178:443/TcpAbridged complete!
2026-09-29 04:05:05,454 INFO telethon.network.mtprotosender: Not disconnecting (already have no connection)
2026-09-29 04:05:05,454 INFO core: Account 2: connecting to Telegram via 91.108.56.181...
2026-09-29 04:05:05,455 INFO telethon.network.mtprotosender: Connecting to 91.108.56.181:443/TcpAbridged...
2026-09-29 04:05:05,461 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 04:10:12,547 WARNING telethon.network.mtprotosender: Attempt 1 at connecting failed: TimeoutError: 
2026-09-29 04:10:12,550 WARNING core: Account 2: connect timed out after 35s
2026-09-29 04:10:12,551 INFO telethon.network.mtprotosender: Disconnecting from 91.108.56.181:443/TcpAbridged...
2026-09-29 04:10:12,552 INFO telethon.network.mtprotosender: Disconnection from 91.108.56.181:443/TcpAbridged complete!
2026-09-29 04:10:12,552 INFO telethon.network.mtprotosender: Not disconnecting (already have no connection)
2026-09-29 04:10:13,984 INFO core: Event loop thread started, running loop forever
2026-09-29 04:10:14,286 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 04:10:14,302 INFO core: _init_accounts coroutine started
2026-09-29 04:10:14,302 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 04:10:14,313 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 04:15:43,743 INFO core: Event loop thread started, running loop forever
2026-09-29 04:15:44,045 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 04:15:44,051 INFO core: _init_accounts coroutine started
2026-09-29 04:15:44,051 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 04:15:44,065 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 04:20:34,410 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 126, in _init_accounts_inner
    accounts = await self._run_db(self.db.get_accounts)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 540, in get_accounts
    with self._conn() as conn:
         ~~~~~~~~~~^^
  File "/opt/alt/python313/lib64/python3.13/contextlib.py", line 141, in __enter__
    return next(self.gen)
  File "/home/wovewbge/quill.nx.kg/db.py", line 59, in _conn
    conn = _pool.connect()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 448, in connect
    return _ConnectionFairy._checkout(self)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 1272, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 712, in checkout
    rec = pool._do_get()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/impl.py", line 178, in _do_get
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/impl.py", line 176, in _do_get
    return self._create_connection()
           ~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection
    return _ConnectionRecord(self)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 674, in __init__
    self.__connect()
    ~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 900, in __connect
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 896, in __connect
    self.dbapi_connection = connection = pool._invoke_creator(self)
                                         ~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 361, in <lambda>
    return lambda rec: creator_fn()
                       ~~~~~~~~~~^^
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-09-29 04:20:34,422 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 04:25:16,778 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 04:30:13,163 INFO core: Event loop thread started, running loop forever
2026-09-29 04:30:13,464 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 04:30:13,471 INFO core: _init_accounts coroutine started
2026-09-29 04:30:13,472 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 04:30:13,476 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 04:35:12,261 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 126, in _init_accounts_inner
    accounts = await self._run_db(self.db.get_accounts)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 540, in get_accounts
    with self._conn() as conn:
         ~~~~~~~~~~^^
  File "/opt/alt/python313/lib64/python3.13/contextlib.py", line 141, in __enter__
    return next(self.gen)
  File "/home/wovewbge/quill.nx.kg/db.py", line 59, in _conn
    conn = _pool.connect()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 448, in connect
    return _ConnectionFairy._checkout(self)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 1272, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 712, in checkout
    rec = pool._do_get()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/impl.py", line 178, in _do_get
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/impl.py", line 176, in _do_get
    return self._create_connection()
           ~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection
    return _ConnectionRecord(self)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 674, in __init__
    self.__connect()
    ~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 900, in __connect
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 896, in __connect
    self.dbapi_connection = connection = pool._invoke_creator(self)
                                         ~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 361, in <lambda>
    return lambda rec: creator_fn()
                       ~~~~~~~~~~^^
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-09-29 04:35:12,290 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 04:40:27,918 INFO core: Event loop thread started, running loop forever
2026-09-29 04:40:28,219 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 04:40:28,224 INFO core: _init_accounts coroutine started
2026-09-29 04:40:28,226 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 04:40:28,232 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 04:45:31,919 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-29 04:45:31,920 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-29 04:45:31,921 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 04:50:48,305 INFO core: Event loop thread started, running loop forever
2026-09-29 04:50:48,606 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 04:50:48,609 INFO core: _init_accounts coroutine started
2026-09-29 04:50:48,611 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 04:50:48,617 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 04:55:11,303 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-29 04:55:11,303 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 04:55:11,305 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-29 05:00:19,377 INFO core: Event loop thread started, running loop forever
2026-09-29 05:00:19,678 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 05:00:19,686 INFO core: _init_accounts coroutine started
2026-09-29 05:00:19,687 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 05:00:19,722 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-29 05:00:19,723 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-29 05:00:19,724 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-29 05:00:19,725 INFO core: _init_accounts_inner: reloading LLM config
2026-09-29 05:00:19,732 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 05:05:04,712 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 05:10:10,437 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-09-29 05:10:10,437 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-09-29 05:10:27,671 INFO core: Event loop thread started, running loop forever
2026-09-29 05:10:27,973 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 05:10:27,977 INFO core: _init_accounts coroutine started
2026-09-29 05:10:27,978 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 05:10:27,982 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 05:15:24,834 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 05:20:12,917 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-09-29 05:20:12,926 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 05:25:50,293 INFO core: Event loop thread started, running loop forever
2026-09-29 05:25:50,594 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 05:25:50,598 INFO core: _init_accounts coroutine started
2026-09-29 05:25:50,600 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 05:25:50,607 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 05:30:52,532 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-09-29 05:30:52,540 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 05:35:43,312 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 05:40:19,253 INFO app: Retrying account initialization (clients=0 but authorized accounts in DB)
2026-09-29 05:40:19,255 INFO core: _init_accounts coroutine started
2026-09-29 05:40:19,256 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 05:40:19,260 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 05:45:26,469 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 149, in _init_accounts_inner
    await self._run_db(self.db.migrate_legacy_session)
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-09-29 05:45:42,520 INFO core: Event loop thread started, running loop forever
2026-09-29 05:45:42,821 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 05:45:42,839 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 05:50:48,499 INFO core: _init_accounts coroutine started
2026-09-29 05:50:48,500 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 05:50:48,517 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-09-29 05:50:53,298 INFO core: Event loop thread started, running loop forever
2026-09-29 05:50:53,599 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 05:50:53,605 INFO core: _init_accounts coroutine started
2026-09-29 05:50:53,605 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 05:50:53,610 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 05:55:31,005 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 06:00:37,430 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 149, in _init_accounts_inner
    await self._run_db(self.db.migrate_legacy_session)
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-09-29 06:00:48,184 INFO core: Event loop thread started, running loop forever
2026-09-29 06:00:48,485 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 06:00:48,501 INFO core: _init_accounts coroutine started
2026-09-29 06:00:48,501 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 06:00:48,534 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 06:05:52,981 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-09-29 06:05:52,984 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 06:10:30,695 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 06:15:40,898 INFO core: Event loop thread started, running loop forever
2026-09-29 06:15:41,199 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 06:15:41,204 INFO core: _init_accounts coroutine started
2026-09-29 06:15:41,205 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 06:15:41,211 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 06:20:49,736 INFO core: Event loop thread started, running loop forever
2026-09-29 06:20:50,044 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 06:20:50,053 INFO core: _init_accounts coroutine started
2026-09-29 06:20:50,053 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 06:20:50,056 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 06:25:17,201 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 06:30:35,136 INFO core: Event loop thread started, running loop forever
2026-09-29 06:30:35,437 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 06:30:35,447 INFO core: _init_accounts coroutine started
2026-09-29 06:30:35,447 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 06:30:35,456 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 06:30:35,467 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-29 06:30:35,467 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-29 06:35:11,203 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-29 06:35:11,278 INFO core: _init_accounts_inner: reloading LLM config
2026-09-29 06:35:11,301 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 06:40:08,040 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 06:45:42,039 INFO core: Event loop thread started, running loop forever
2026-09-29 06:45:42,340 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 06:45:42,343 INFO core: _init_accounts coroutine started
2026-09-29 06:45:42,344 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 06:45:42,349 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 06:50:17,147 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 06:50:17,148 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-29 06:50:17,149 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-29 06:55:24,452 WARNING core: ensure_llm_schema failed: cannot schedule new futures after interpreter shutdown
2026-09-29 06:55:41,034 INFO core: Event loop thread started, running loop forever
2026-09-29 06:55:41,336 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 06:55:41,341 INFO core: _init_accounts coroutine started
2026-09-29 06:55:41,342 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 06:55:41,348 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 07:00:06,634 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 07:05:13,420 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-29 07:05:13,420 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-29 07:05:13,421 WARNING core: ensure_llm_schema failed: cannot schedule new futures after shutdown
2026-09-29 07:05:13,422 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-29 07:05:13,422 WARNING core: ensure_pair_schema failed: cannot schedule new futures after shutdown
2026-09-29 07:05:13,422 INFO core: _init_accounts_inner: reloading LLM config
2026-09-29 07:05:13,422 WARNING core: LLM config load failed: cannot schedule new futures after shutdown
2026-09-29 07:05:13,422 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-09-29 07:05:26,674 INFO core: Event loop thread started, running loop forever
2026-09-29 07:05:26,975 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 07:05:26,979 INFO core: _init_accounts coroutine started
2026-09-29 07:05:26,982 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 07:05:26,987 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 07:10:17,962 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 07:15:32,770 INFO core: Event loop thread started, running loop forever
2026-09-29 07:15:33,071 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 07:15:33,074 INFO core: _init_accounts coroutine started
2026-09-29 07:15:33,077 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 07:15:33,090 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 07:20:38,287 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-09-29 07:20:38,303 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 07:25:09,236 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 07:30:52,530 INFO core: Event loop thread started, running loop forever
2026-09-29 07:30:52,831 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 07:30:52,836 INFO core: _init_accounts coroutine started
2026-09-29 07:30:52,837 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 07:30:52,845 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 07:30:52,847 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-29 07:30:52,847 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-29 07:35:46,123 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-29 07:35:46,139 INFO core: _init_accounts_inner: reloading LLM config
2026-09-29 07:35:46,152 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 07:40:13,127 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 07:45:20,451 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-09-29 07:45:43,228 INFO core: Event loop thread started, running loop forever
2026-09-29 07:45:43,529 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 07:45:43,533 INFO core: _init_accounts coroutine started
2026-09-29 07:45:43,535 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 07:45:43,543 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 07:50:22,279 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-29 07:50:22,280 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-29 07:50:22,281 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 07:55:35,141 INFO core: Event loop thread started, running loop forever
2026-09-29 07:55:35,442 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 07:55:35,447 INFO core: _init_accounts coroutine started
2026-09-29 07:55:35,448 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 07:55:35,454 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 08:00:12,491 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-29 08:00:12,493 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-29 08:00:12,494 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 08:05:43,261 INFO core: Event loop thread started, running loop forever
2026-09-29 08:05:43,562 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 08:05:43,567 INFO core: _init_accounts coroutine started
2026-09-29 08:05:43,568 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 08:05:43,577 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 08:10:26,975 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-09-29 08:10:26,988 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 08:15:07,660 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 08:20:11,159 INFO app: Retrying account initialization (clients=0 but authorized accounts in DB)
2026-09-29 08:20:11,161 INFO core: _init_accounts coroutine started
2026-09-29 08:20:11,161 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 08:20:11,165 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 08:25:21,466 INFO core: Event loop thread started, running loop forever
2026-09-29 08:25:21,767 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 08:25:21,773 INFO core: _init_accounts coroutine started
2026-09-29 08:25:21,775 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 08:25:21,787 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 08:30:47,841 INFO core: Event loop thread started, running loop forever
2026-09-29 08:30:48,142 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 08:30:48,148 INFO core: _init_accounts coroutine started
2026-09-29 08:30:48,148 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 08:30:48,154 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 08:35:27,758 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-29 08:35:27,760 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-29 08:35:27,761 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-29 08:35:27,762 INFO core: _init_accounts_inner: reloading LLM config
2026-09-29 08:35:27,778 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-09-29 08:35:27,779 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-09-29 08:35:27,784 INFO core: Account 2: connecting to Telegram via 91.108.56.178...
2026-09-29 08:35:27,785 INFO telethon.network.mtprotosender: Connecting to 91.108.56.178:443/TcpAbridged...
2026-09-29 08:35:27,799 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 08:40:07,782 WARNING telethon.network.mtprotosender: Attempt 1 at connecting failed: TimeoutError: 
2026-09-29 08:40:07,783 WARNING core: Account 2: connect timed out after 35s
2026-09-29 08:40:07,784 INFO telethon.network.mtprotosender: Disconnecting from 91.108.56.178:443/TcpAbridged...
2026-09-29 08:40:07,784 INFO telethon.network.mtprotosender: Disconnection from 91.108.56.178:443/TcpAbridged complete!
2026-09-29 08:40:07,785 INFO telethon.network.mtprotosender: Not disconnecting (already have no connection)
2026-09-29 08:40:07,786 INFO core: Account 2: connecting to Telegram via 91.108.56.181...
2026-09-29 08:40:07,787 INFO telethon.network.mtprotosender: Connecting to 91.108.56.181:443/TcpAbridged...
2026-09-29 08:40:07,795 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 08:45:13,481 WARNING telethon.network.mtprotosender: Attempt 1 at connecting failed: TimeoutError: 
2026-09-29 08:45:13,482 WARNING core: Account 2: connect timed out after 35s
2026-09-29 08:45:13,482 INFO telethon.network.mtprotosender: Disconnecting from 91.108.56.181:443/TcpAbridged...
2026-09-29 08:45:13,483 INFO telethon.network.mtprotosender: Disconnection from 91.108.56.181:443/TcpAbridged complete!
2026-09-29 08:45:13,483 INFO telethon.network.mtprotosender: Not disconnecting (already have no connection)
2026-09-29 08:45:13,484 INFO core: Account 2: connecting to Telegram via 91.108.56.182...
2026-09-29 08:45:13,484 INFO telethon.network.mtprotosender: Connecting to 91.108.56.182:443/TcpAbridged...
2026-09-29 08:45:51,822 INFO core: Event loop thread started, running loop forever
2026-09-29 08:45:52,123 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 08:45:52,130 INFO core: _init_accounts coroutine started
2026-09-29 08:45:52,132 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 08:45:52,137 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 08:50:18,465 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-29 08:50:18,465 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-29 08:50:18,470 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-29 08:50:18,471 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 08:50:18,472 INFO core: _init_accounts_inner: reloading LLM config
2026-09-29 08:55:24,302 INFO core: Event loop thread started, running loop forever
2026-09-29 08:55:24,602 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 08:55:24,617 INFO core: _init_accounts coroutine started
2026-09-29 08:55:24,618 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 08:55:24,629 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 09:00:19,823 INFO core: Event loop thread started, running loop forever
2026-09-29 09:00:20,125 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 09:00:20,131 INFO core: _init_accounts coroutine started
2026-09-29 09:00:20,131 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 09:00:20,135 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 09:05:32,578 INFO core: Event loop thread started, running loop forever
2026-09-29 09:05:32,884 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 09:05:32,891 INFO core: _init_accounts coroutine started
2026-09-29 09:05:32,891 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 09:05:32,906 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 09:10:39,874 INFO core: Event loop thread started, running loop forever
2026-09-29 09:10:40,175 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 09:10:40,184 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 09:15:19,598 INFO core: _init_accounts coroutine started
2026-09-29 09:15:19,600 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 09:15:19,605 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 09:20:31,616 INFO core: Event loop thread started, running loop forever
2026-09-29 09:20:31,917 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 09:20:31,922 INFO core: _init_accounts coroutine started
2026-09-29 09:20:31,923 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 09:20:31,929 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 09:25:19,134 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 09:30:26,450 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 126, in _init_accounts_inner
    accounts = await self._run_db(self.db.get_accounts)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 540, in get_accounts
    with self._conn() as conn:
         ~~~~~~~~~~^^
  File "/opt/alt/python313/lib64/python3.13/contextlib.py", line 141, in __enter__
    return next(self.gen)
  File "/home/wovewbge/quill.nx.kg/db.py", line 59, in _conn
    conn = _pool.connect()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 448, in connect
    return _ConnectionFairy._checkout(self)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 1272, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 717, in checkout
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 715, in checkout
    dbapi_connection = rec.get_connection()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 866, in get_connection
    self.__connect()
    ~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 900, in __connect
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 896, in __connect
    self.dbapi_connection = connection = pool._invoke_creator(self)
                                         ~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 361, in <lambda>
    return lambda rec: creator_fn()
                       ~~~~~~~~~~^^
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-09-29 09:30:40,542 INFO core: Event loop thread started, running loop forever
2026-09-29 09:30:40,843 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 09:30:40,847 INFO core: _init_accounts coroutine started
2026-09-29 09:30:40,848 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 09:30:40,859 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-29 09:30:40,859 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-29 09:30:40,860 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-29 09:30:40,863 INFO core: _init_accounts_inner: reloading LLM config
2026-09-29 09:30:40,867 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 09:35:47,501 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-09-29 09:35:47,501 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-09-29 09:35:47,502 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 180, in _init_accounts_inner
    await self._start_account_client(acct["id"])
  File "/home/wovewbge/quill.nx.kg/core.py", line 236, in _start_account_client
    session_str = await self._run_db(self.db.get_account_session, account_id)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-09-29 09:35:49,883 INFO core: Event loop thread started, running loop forever
2026-09-29 09:35:50,184 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 09:35:50,188 INFO core: _init_accounts coroutine started
2026-09-29 09:35:50,190 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 09:35:50,195 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 09:40:15,711 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 09:45:15,986 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 09:50:07,457 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 149, in _init_accounts_inner
    await self._run_db(self.db.migrate_legacy_session)
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 687, in migrate_legacy_session
    with self._conn() as conn:
         ~~~~~~~~~~^^
  File "/opt/alt/python313/lib64/python3.13/contextlib.py", line 141, in __enter__
    return next(self.gen)
  File "/home/wovewbge/quill.nx.kg/db.py", line 59, in _conn
    conn = _pool.connect()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 448, in connect
    return _ConnectionFairy._checkout(self)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 1272, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 712, in checkout
    rec = pool._do_get()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/impl.py", line 178, in _do_get
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/impl.py", line 176, in _do_get
    return self._create_connection()
           ~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection
    return _ConnectionRecord(self)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 674, in __init__
    self.__connect()
    ~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 900, in __connect
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 896, in __connect
    self.dbapi_connection = connection = pool._invoke_creator(self)
                                         ~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 361, in <lambda>
    return lambda rec: creator_fn()
                       ~~~~~~~~~~^^
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-09-29 09:50:07,465 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 09:55:22,563 INFO core: Event loop thread started, running loop forever
2026-09-29 09:55:22,864 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 09:55:22,868 INFO core: _init_accounts coroutine started
2026-09-29 09:55:22,871 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 09:55:22,876 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 10:00:14,889 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 10:05:39,832 INFO core: Event loop thread started, running loop forever
2026-09-29 10:05:40,134 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 10:05:40,138 INFO core: _init_accounts coroutine started
2026-09-29 10:05:40,144 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 10:05:40,148 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 10:10:40,065 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-29 10:10:40,065 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-29 10:10:40,066 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 10:15:29,729 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-29 10:15:29,733 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 10:15:52,866 INFO core: _init_accounts_inner: reloading LLM config
2026-09-29 10:15:52,869 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 10:20:26,051 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 10:25:32,428 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-09-29 10:25:32,429 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-09-29 10:25:48,438 INFO core: Event loop thread started, running loop forever
2026-09-29 10:25:48,739 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 10:25:48,751 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 10:25:48,751 INFO core: _init_accounts coroutine started
2026-09-29 10:25:48,753 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 10:30:34,025 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 10:35:11,355 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 10:35:11,355 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-29 10:35:11,356 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-29 10:40:12,367 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-29 10:40:12,372 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 10:45:23,035 INFO core: Event loop thread started, running loop forever
2026-09-29 10:45:23,336 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 10:45:23,343 INFO core: _init_accounts coroutine started
2026-09-29 10:45:23,344 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 10:45:23,353 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-29 10:45:23,353 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-29 10:45:23,354 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-29 10:45:23,356 INFO core: _init_accounts_inner: reloading LLM config
2026-09-29 10:45:23,375 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-09-29 10:45:23,376 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-09-29 10:45:23,379 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 10:50:21,650 INFO core: Account 2: connecting to Telegram via 91.108.56.178...
2026-09-29 10:50:21,651 INFO telethon.network.mtprotosender: Connecting to 91.108.56.178:443/TcpAbridged...
2026-09-29 10:50:21,655 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 10:55:27,414 WARNING telethon.network.mtprotosender: Attempt 1 at connecting failed: TimeoutError: 
2026-09-29 10:55:27,416 WARNING core: Account 2: connect timed out after 35s
2026-09-29 10:55:27,417 INFO telethon.network.mtprotosender: Disconnecting from 91.108.56.178:443/TcpAbridged...
2026-09-29 10:55:27,417 INFO telethon.network.mtprotosender: Disconnection from 91.108.56.178:443/TcpAbridged complete!
2026-09-29 10:55:27,418 INFO telethon.network.mtprotosender: Not disconnecting (already have no connection)
2026-09-29 10:55:27,419 INFO core: Account 2: connecting to Telegram via 91.108.56.181...
2026-09-29 10:55:43,959 INFO core: Event loop thread started, running loop forever
2026-09-29 10:55:44,260 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 10:55:44,267 INFO core: _init_accounts coroutine started
2026-09-29 10:55:44,268 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 10:55:44,280 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 11:00:42,412 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-29 11:00:42,412 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-29 11:00:42,414 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 11:05:11,927 INFO core: Event loop thread started, running loop forever
2026-09-29 11:05:12,228 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 11:05:12,236 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 11:05:49,975 WARNING core: ensure_llm_schema failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-09-29 11:05:49,976 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-29 11:05:49,977 WARNING core: ensure_pair_schema failed: cannot schedule new futures after shutdown
2026-09-29 11:10:19,426 INFO core: _init_accounts coroutine started
2026-09-29 11:10:19,427 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 11:10:23,269 INFO core: Event loop thread started, running loop forever
2026-09-29 11:10:23,570 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 11:10:23,574 INFO core: _init_accounts coroutine started
2026-09-29 11:10:23,576 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 11:10:23,590 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 11:15:51,640 INFO core: Event loop thread started, running loop forever
2026-09-29 11:15:51,941 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 11:15:51,944 INFO core: _init_accounts coroutine started
2026-09-29 11:15:51,945 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 11:15:51,949 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 11:20:13,055 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-29 11:20:13,055 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-29 11:20:13,057 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-29 11:20:13,060 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 11:25:11,793 INFO core: _init_accounts_inner: reloading LLM config
2026-09-29 11:25:11,808 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 11:30:17,392 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-09-29 11:30:17,392 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-09-29 11:30:17,393 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 180, in _init_accounts_inner
    await self._start_account_client(acct["id"])
  File "/home/wovewbge/quill.nx.kg/core.py", line 236, in _start_account_client
    session_str = await self._run_db(self.db.get_account_session, account_id)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-09-29 11:30:42,968 INFO core: Event loop thread started, running loop forever
2026-09-29 11:30:43,269 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 11:30:43,273 INFO core: _init_accounts coroutine started
2026-09-29 11:30:43,275 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 11:30:43,285 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-29 11:30:43,285 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-29 11:30:43,286 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-29 11:30:43,287 INFO core: _init_accounts_inner: reloading LLM config
2026-09-29 11:30:43,290 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 11:35:53,697 INFO core: Event loop thread started, running loop forever
2026-09-29 11:35:53,997 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 11:35:54,007 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 11:40:29,582 INFO core: _init_accounts coroutine started
2026-09-29 11:40:29,582 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 11:40:29,595 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 11:45:19,629 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-29 11:45:19,629 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-29 11:45:19,630 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 11:50:25,621 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-29 11:50:54,035 INFO core: Event loop thread started, running loop forever
2026-09-29 11:50:54,338 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 11:50:54,342 INFO core: _init_accounts coroutine started
2026-09-29 11:50:54,345 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 11:50:54,354 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 11:55:23,478 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-09-29 11:55:23,531 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 12:00:50,702 INFO core: Event loop thread started, running loop forever
2026-09-29 12:00:51,003 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 12:00:51,009 INFO core: _init_accounts coroutine started
2026-09-29 12:00:51,021 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 12:00:51,053 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 12:05:37,141 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-29 12:05:37,143 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 12:05:37,143 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-29 12:10:10,438 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 12:15:17,491 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-29 12:15:17,501 INFO core: _init_accounts_inner: reloading LLM config
2026-09-29 12:15:17,501 WARNING core: LLM config load failed: cannot schedule new futures after shutdown
2026-09-29 12:15:17,502 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-09-29 12:15:19,571 INFO core: Event loop thread started, running loop forever
2026-09-29 12:15:19,872 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 12:15:19,876 INFO core: _init_accounts coroutine started
2026-09-29 12:15:19,878 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 12:15:19,884 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 12:20:16,594 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-29 12:20:16,595 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-29 12:20:16,614 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 12:25:22,533 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-29 12:25:37,437 INFO core: Event loop thread started, running loop forever
2026-09-29 12:25:37,738 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 12:25:37,742 INFO core: _init_accounts coroutine started
2026-09-29 12:25:37,742 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 12:25:37,755 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 12:30:50,001 INFO core: Event loop thread started, running loop forever
2026-09-29 12:30:50,303 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 12:30:50,307 INFO core: _init_accounts coroutine started
2026-09-29 12:30:50,309 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 12:30:50,317 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 12:35:05,904 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-29 12:35:05,904 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-29 12:35:05,906 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-29 12:35:05,908 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 12:35:05,909 INFO core: _init_accounts_inner: reloading LLM config
2026-09-29 12:40:43,270 INFO core: Event loop thread started, running loop forever
2026-09-29 12:40:43,572 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 12:40:43,575 INFO core: _init_accounts coroutine started
2026-09-29 12:40:43,575 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 12:40:43,588 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 12:45:50,472 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-09-29 12:45:51,359 INFO core: Event loop thread started, running loop forever
2026-09-29 12:45:51,661 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 12:45:51,670 INFO core: _init_accounts coroutine started
2026-09-29 12:45:51,670 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 12:45:51,675 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 12:50:49,600 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 12:55:24,553 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 13:00:30,420 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-29 13:00:30,563 INFO core: Event loop thread started, running loop forever
2026-09-29 13:00:30,871 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 13:00:30,878 INFO core: _init_accounts coroutine started
2026-09-29 13:00:30,879 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 13:00:30,886 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 13:05:22,184 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 13:10:43,066 INFO core: Event loop thread started, running loop forever
2026-09-29 13:10:43,367 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 13:10:43,371 INFO core: _init_accounts coroutine started
2026-09-29 13:10:43,373 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 13:10:43,378 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 13:15:50,408 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 149, in _init_accounts_inner
    await self._run_db(self.db.migrate_legacy_session)
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-09-29 13:15:52,421 INFO core: Event loop thread started, running loop forever
2026-09-29 13:15:52,722 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 13:15:52,728 INFO core: _init_accounts coroutine started
2026-09-29 13:15:52,729 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 13:15:52,732 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 13:20:34,247 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 13:25:40,488 INFO core: Event loop thread started, running loop forever
2026-09-29 13:25:40,790 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 13:25:40,797 INFO core: _init_accounts coroutine started
2026-09-29 13:25:40,798 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 13:25:40,853 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 13:30:29,312 INFO core: Event loop thread started, running loop forever
2026-09-29 13:30:29,613 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 13:30:29,616 INFO core: _init_accounts coroutine started
2026-09-29 13:30:29,616 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 13:30:29,625 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-29 13:30:29,625 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-29 13:30:29,627 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-29 13:30:29,627 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 13:30:29,630 INFO core: _init_accounts_inner: reloading LLM config
2026-09-29 13:35:07,697 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-09-29 13:35:07,697 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-09-29 13:35:07,702 INFO core: Account 2: connecting to Telegram via 91.108.56.178...
2026-09-29 13:35:07,703 INFO telethon.network.mtprotosender: Connecting to 91.108.56.178:443/TcpAbridged...
2026-09-29 13:35:07,767 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 13:40:13,476 WARNING telethon.network.mtprotosender: Attempt 1 at connecting failed: TimeoutError: 
2026-09-29 13:40:13,477 WARNING core: Account 2: connect timed out after 35s
2026-09-29 13:40:13,478 INFO telethon.network.mtprotosender: Disconnecting from 91.108.56.178:443/TcpAbridged...
2026-09-29 13:40:13,478 INFO telethon.network.mtprotosender: Disconnection from 91.108.56.178:443/TcpAbridged complete!
2026-09-29 13:40:13,480 INFO telethon.network.mtprotosender: Not disconnecting (already have no connection)
2026-09-29 13:40:13,481 INFO core: Account 2: connecting to Telegram via 91.108.56.181...
2026-09-29 13:40:13,482 INFO telethon.network.mtprotosender: Connecting to 91.108.56.181:443/TcpAbridged...
2026-09-29 13:40:20,234 INFO core: Event loop thread started, running loop forever
2026-09-29 13:40:20,542 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 13:40:20,553 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 13:45:53,167 INFO core: Event loop thread started, running loop forever
2026-09-29 13:45:53,468 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 13:45:53,483 INFO core: _init_accounts coroutine started
2026-09-29 13:45:53,483 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 13:45:53,499 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-29 13:45:53,499 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-29 13:45:53,501 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-29 13:45:53,504 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 13:50:16,920 INFO core: _init_accounts_inner: reloading LLM config
2026-09-29 13:50:16,927 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 13:55:29,975 INFO core: Event loop thread started, running loop forever
2026-09-29 13:55:30,276 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 13:55:30,281 INFO core: _init_accounts coroutine started
2026-09-29 13:55:30,282 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 13:55:30,286 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 14:00:35,950 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-29 14:00:35,950 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-29 14:00:35,954 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-29 14:00:35,957 INFO core: _init_accounts_inner: reloading LLM config
2026-09-29 14:00:35,977 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 14:05:46,100 INFO core: Event loop thread started, running loop forever
2026-09-29 14:05:46,401 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 14:05:46,404 INFO core: _init_accounts coroutine started
2026-09-29 14:05:46,407 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 14:05:46,413 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 14:10:23,457 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-29 14:10:23,457 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-29 14:10:23,459 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-29 14:10:23,461 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 14:12:45,584 INFO core: _init_accounts_inner: reloading LLM config
2026-09-29 14:12:45,595 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 14:15:49,808 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 14:15:49,811 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-09-29 14:20:25,296 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-09-29 14:20:25,325 INFO core: Account 2: connecting to Telegram via 91.108.56.178...
2026-09-29 14:20:25,326 INFO telethon.network.mtprotosender: Connecting to 91.108.56.178:443/TcpAbridged...
2026-09-29 14:20:25,330 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 14:25:16,082 WARNING telethon.network.mtprotosender: Attempt 1 at connecting failed: TimeoutError: 
2026-09-29 14:25:16,083 WARNING core: Account 2: connect timed out after 35s
2026-09-29 14:25:16,084 INFO telethon.network.mtprotosender: Disconnecting from 91.108.56.178:443/TcpAbridged...
2026-09-29 14:25:16,085 INFO telethon.network.mtprotosender: Disconnection from 91.108.56.178:443/TcpAbridged complete!
2026-09-29 14:25:16,086 INFO telethon.network.mtprotosender: Not disconnecting (already have no connection)
2026-09-29 14:25:16,086 INFO core: Account 2: connecting to Telegram via 91.108.56.181...
2026-09-29 14:25:16,087 INFO telethon.network.mtprotosender: Connecting to 91.108.56.181:443/TcpAbridged...
2026-09-29 14:25:16,096 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 14:30:22,417 WARNING telethon.network.mtprotosender: Attempt 1 at connecting failed: TimeoutError: 
2026-09-29 14:30:22,418 WARNING core: Account 2: connect timed out after 35s
2026-09-29 14:30:22,419 INFO telethon.network.mtprotosender: Disconnecting from 91.108.56.181:443/TcpAbridged...
2026-09-29 14:30:22,419 INFO telethon.network.mtprotosender: Disconnection from 91.108.56.181:443/TcpAbridged complete!
2026-09-29 14:30:22,420 INFO telethon.network.mtprotosender: Not disconnecting (already have no connection)
2026-09-29 14:30:22,421 INFO core: Account 2: connecting to Telegram via 91.108.56.182...
2026-09-29 14:30:22,422 INFO telethon.network.mtprotosender: Connecting to 91.108.56.182:443/TcpAbridged...
2026-09-29 14:30:46,079 INFO core: Event loop thread started, running loop forever
2026-09-29 14:30:46,380 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 14:30:46,388 INFO core: _init_accounts coroutine started
2026-09-29 14:30:46,399 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 14:30:46,437 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-29 14:30:46,437 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-29 14:30:46,445 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 14:30:46,449 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-29 14:30:46,451 INFO core: _init_accounts_inner: reloading LLM config
2026-09-29 14:35:42,168 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 14:40:49,502 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-09-29 14:40:52,251 INFO core: Event loop thread started, running loop forever
2026-09-29 14:40:52,557 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 14:40:52,565 INFO core: _init_accounts coroutine started
2026-09-29 14:40:52,565 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 14:40:52,580 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 14:45:49,019 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 14:50:30,263 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 14:55:53,313 INFO core: Event loop thread started, running loop forever
2026-09-29 14:55:53,614 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 14:55:53,620 INFO core: _init_accounts coroutine started
2026-09-29 14:55:53,620 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 14:55:53,628 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-29 14:55:53,628 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-29 14:55:53,629 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 14:55:53,632 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-29 15:00:10,185 INFO core: _init_accounts_inner: reloading LLM config
2026-09-29 15:00:10,203 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 15:05:50,698 INFO core: Event loop thread started, running loop forever
2026-09-29 15:05:50,998 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 15:05:51,002 INFO core: _init_accounts coroutine started
2026-09-29 15:05:51,004 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 15:05:51,012 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 15:10:11,672 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 15:15:47,719 INFO core: Event loop thread started, running loop forever
2026-09-29 15:15:48,020 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 15:15:48,024 INFO core: _init_accounts coroutine started
2026-09-29 15:15:48,024 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 15:15:48,049 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 15:20:07,355 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-09-29 15:20:07,368 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 15:25:28,660 INFO core: Event loop thread started, running loop forever
2026-09-29 15:25:28,961 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 15:25:28,967 INFO core: _init_accounts coroutine started
2026-09-29 15:25:28,969 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 15:25:28,975 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 15:30:53,671 INFO core: Event loop thread started, running loop forever
2026-09-29 15:30:53,972 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 15:30:53,980 INFO core: _init_accounts coroutine started
2026-09-29 15:30:53,980 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 15:30:53,986 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 15:35:37,178 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-09-29 15:35:37,194 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 15:40:48,866 INFO core: Event loop thread started, running loop forever
2026-09-29 15:40:49,167 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 15:40:49,177 INFO core: _init_accounts coroutine started
2026-09-29 15:40:49,179 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 15:40:49,184 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 15:45:22,457 INFO core: Event loop thread started, running loop forever
2026-09-29 15:45:22,768 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 15:45:22,776 INFO core: _init_accounts coroutine started
2026-09-29 15:45:22,777 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 15:45:22,780 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 15:50:17,595 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 15:55:23,467 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-29 15:55:30,234 INFO core: Event loop thread started, running loop forever
2026-09-29 15:55:30,548 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 15:55:30,554 INFO core: _init_accounts coroutine started
2026-09-29 15:55:30,554 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 15:55:30,561 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 16:00:32,862 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 16:05:39,160 INFO core: Event loop thread started, running loop forever
2026-09-29 16:05:39,461 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 16:05:39,465 INFO core: _init_accounts coroutine started
2026-09-29 16:05:39,466 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 16:05:39,471 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 16:10:46,418 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 149, in _init_accounts_inner
    await self._run_db(self.db.migrate_legacy_session)
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-09-29 16:10:48,920 INFO core: Event loop thread started, running loop forever
2026-09-29 16:10:49,220 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 16:10:49,223 INFO core: _init_accounts coroutine started
2026-09-29 16:10:49,224 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 16:10:49,230 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 16:15:21,806 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 16:20:10,518 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 16:25:28,314 INFO core: Event loop thread started, running loop forever
2026-09-29 16:25:28,615 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 16:25:28,621 INFO core: _init_accounts coroutine started
2026-09-29 16:25:28,621 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 16:25:28,630 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 16:30:15,036 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 16:35:21,726 INFO core: Event loop thread started, running loop forever
2026-09-29 16:35:22,027 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 16:35:22,033 INFO core: _init_accounts coroutine started
2026-09-29 16:35:22,033 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 16:35:22,041 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 16:40:13,400 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-29 16:40:13,400 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-29 16:40:13,404 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-29 16:40:13,405 INFO core: _init_accounts_inner: reloading LLM config
2026-09-29 16:40:13,423 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 16:45:17,168 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-09-29 16:45:17,169 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-09-29 16:45:17,176 INFO core: Account 2: connecting to Telegram via 91.108.56.178...
2026-09-29 16:45:17,177 INFO telethon.network.mtprotosender: Connecting to 91.108.56.178:443/TcpAbridged...
2026-09-29 16:45:17,183 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 16:50:10,232 WARNING telethon.network.mtprotosender: Attempt 1 at connecting failed: TimeoutError: 
2026-09-29 16:50:10,233 WARNING core: Account 2: connect timed out after 35s
2026-09-29 16:50:10,234 INFO telethon.network.mtprotosender: Disconnecting from 91.108.56.178:443/TcpAbridged...
2026-09-29 16:50:10,234 INFO telethon.network.mtprotosender: Disconnection from 91.108.56.178:443/TcpAbridged complete!
2026-09-29 16:50:10,235 INFO telethon.network.mtprotosender: Not disconnecting (already have no connection)
2026-09-29 16:50:10,236 INFO core: Account 2: connecting to Telegram via 91.108.56.181...
2026-09-29 16:50:10,237 INFO telethon.network.mtprotosender: Connecting to 91.108.56.181:443/TcpAbridged...
2026-09-29 16:50:10,248 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 16:55:17,534 WARNING telethon.network.mtprotosender: Attempt 1 at connecting failed: TimeoutError: 
2026-09-29 16:55:17,534 WARNING core: Account 2: connect timed out after 35s
2026-09-29 16:55:17,535 INFO telethon.network.mtprotosender: Disconnecting from 91.108.56.181:443/TcpAbridged...
2026-09-29 16:55:17,535 INFO telethon.network.mtprotosender: Disconnection from 91.108.56.181:443/TcpAbridged complete!
2026-09-29 16:55:17,535 INFO telethon.network.mtprotosender: Not disconnecting (already have no connection)
2026-09-29 16:55:17,536 INFO core: Account 2: connecting to Telegram via 91.108.56.182...
2026-09-29 16:55:17,536 INFO telethon.network.mtprotosender: Connecting to 91.108.56.182:443/TcpAbridged...
2026-09-29 16:55:33,180 INFO core: Event loop thread started, running loop forever
2026-09-29 16:55:33,481 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 16:55:33,485 INFO core: _init_accounts coroutine started
2026-09-29 16:55:33,487 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 16:55:33,492 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 17:00:38,059 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 17:05:34,779 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-29 17:05:34,780 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-29 17:05:34,783 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-29 17:05:34,784 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 17:10:08,432 INFO core: _init_accounts_inner: reloading LLM config
2026-09-29 17:10:08,442 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 17:15:09,909 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 17:20:47,286 INFO core: Event loop thread started, running loop forever
2026-09-29 17:20:47,588 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 17:20:47,592 INFO core: _init_accounts coroutine started
2026-09-29 17:20:47,594 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 17:20:47,601 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 17:25:16,672 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 17:30:22,416 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 149, in _init_accounts_inner
    await self._run_db(self.db.migrate_legacy_session)
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 687, in migrate_legacy_session
    with self._conn() as conn:
         ~~~~~~~~~~^^
  File "/opt/alt/python313/lib64/python3.13/contextlib.py", line 141, in __enter__
    return next(self.gen)
  File "/home/wovewbge/quill.nx.kg/db.py", line 59, in _conn
    conn = _pool.connect()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 448, in connect
    return _ConnectionFairy._checkout(self)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 1272, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 717, in checkout
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 715, in checkout
    dbapi_connection = rec.get_connection()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 866, in get_connection
    self.__connect()
    ~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 900, in __connect
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 896, in __connect
    self.dbapi_connection = connection = pool._invoke_creator(self)
                                         ~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 361, in <lambda>
    return lambda rec: creator_fn()
                       ~~~~~~~~~~^^
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-09-29 17:30:49,480 INFO core: Event loop thread started, running loop forever
2026-09-29 17:30:49,781 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 17:30:49,787 INFO core: _init_accounts coroutine started
2026-09-29 17:30:49,788 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 17:30:49,806 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-29 17:30:49,806 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-29 17:30:49,806 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 17:30:49,808 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-29 17:35:04,166 INFO core: _init_accounts_inner: reloading LLM config
2026-09-29 17:35:04,211 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-09-29 17:35:04,211 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-09-29 17:35:04,229 INFO core: Account 2: connecting to Telegram via 91.108.56.178...
2026-09-29 17:35:04,230 INFO telethon.network.mtprotosender: Connecting to 91.108.56.178:443/TcpAbridged...
2026-09-29 17:35:04,232 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 17:40:10,470 WARNING telethon.network.mtprotosender: Attempt 1 at connecting failed: TimeoutError: 
2026-09-29 17:40:10,470 WARNING core: Account 2: connect timed out after 35s
2026-09-29 17:40:10,471 INFO telethon.network.mtprotosender: Disconnecting from 91.108.56.178:443/TcpAbridged...
2026-09-29 17:40:10,471 INFO telethon.network.mtprotosender: Disconnection from 91.108.56.178:443/TcpAbridged complete!
2026-09-29 17:40:10,471 INFO telethon.network.mtprotosender: Not disconnecting (already have no connection)
2026-09-29 17:40:10,472 INFO core: Account 2: connecting to Telegram via 91.108.56.181...
2026-09-29 17:40:10,472 INFO telethon.network.mtprotosender: Connecting to 91.108.56.181:443/TcpAbridged...
2026-09-29 17:40:52,792 INFO core: Event loop thread started, running loop forever
2026-09-29 17:40:53,093 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 17:40:53,107 INFO core: _init_accounts coroutine started
2026-09-29 17:40:53,107 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 17:40:53,114 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 17:45:07,721 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-09-29 17:45:07,728 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 17:50:29,561 INFO core: Event loop thread started, running loop forever
2026-09-29 17:50:29,862 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 17:50:29,866 INFO core: _init_accounts coroutine started
2026-09-29 17:50:29,867 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 17:50:29,873 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 17:55:09,561 INFO core: Event loop thread started, running loop forever
2026-09-29 17:55:09,862 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 17:55:09,869 INFO core: _init_accounts coroutine started
2026-09-29 17:55:09,870 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 17:55:09,873 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 18:00:16,435 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-09-29 18:00:40,559 INFO core: Event loop thread started, running loop forever
2026-09-29 18:00:40,860 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 18:00:40,866 INFO core: _init_accounts coroutine started
2026-09-29 18:00:40,867 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 18:00:40,873 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 18:05:19,899 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 18:10:24,813 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-09-29 18:10:24,821 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 18:15:06,298 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 18:20:04,879 INFO app: Retrying account initialization (clients=0 but authorized accounts in DB)
2026-09-29 18:20:04,881 INFO core: _init_accounts coroutine started
2026-09-29 18:20:04,881 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 18:20:04,890 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-29 18:20:04,890 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-29 18:20:04,897 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-29 18:20:04,900 INFO core: _init_accounts_inner: reloading LLM config
2026-09-29 18:20:04,906 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 18:25:24,183 INFO core: Event loop thread started, running loop forever
2026-09-29 18:25:24,484 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 18:25:24,488 INFO core: _init_accounts coroutine started
2026-09-29 18:25:24,490 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 18:25:24,495 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 18:30:50,421 INFO core: Event loop thread started, running loop forever
2026-09-29 18:30:50,724 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 18:30:50,738 INFO core: _init_accounts coroutine started
2026-09-29 18:30:50,742 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 18:30:50,738 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 18:35:29,434 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 18:40:39,172 INFO core: Event loop thread started, running loop forever
2026-09-29 18:40:39,475 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 18:40:39,478 INFO core: _init_accounts coroutine started
2026-09-29 18:40:39,481 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 18:40:39,485 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 18:45:30,776 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 18:50:23,361 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 18:55:30,469 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-29 18:55:30,469 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-29 18:55:30,469 WARNING core: ensure_llm_schema failed: cannot schedule new futures after shutdown
2026-09-29 18:55:30,470 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-29 18:55:30,470 WARNING core: ensure_pair_schema failed: cannot schedule new futures after shutdown
2026-09-29 18:55:30,470 INFO core: _init_accounts_inner: reloading LLM config
2026-09-29 18:55:30,470 WARNING core: LLM config load failed: cannot schedule new futures after shutdown
2026-09-29 18:55:30,470 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-09-29 18:55:30,471 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 180, in _init_accounts_inner
    await self._start_account_client(acct["id"])
  File "/home/wovewbge/quill.nx.kg/core.py", line 236, in _start_account_client
    session_str = await self._run_db(self.db.get_account_session, account_id)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-09-29 18:55:36,112 INFO core: Event loop thread started, running loop forever
2026-09-29 18:55:36,413 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 18:55:36,416 INFO core: _init_accounts coroutine started
2026-09-29 18:55:36,417 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 18:55:36,424 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 19:00:09,745 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 19:05:16,505 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-29 19:05:16,506 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-29 19:05:16,506 WARNING core: ensure_llm_schema failed: cannot schedule new futures after shutdown
2026-09-29 19:05:16,507 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-29 19:05:16,507 WARNING core: ensure_pair_schema failed: cannot schedule new futures after shutdown
2026-09-29 19:05:16,507 INFO core: _init_accounts_inner: reloading LLM config
2026-09-29 19:05:16,507 WARNING core: LLM config load failed: cannot schedule new futures after shutdown
2026-09-29 19:05:16,507 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-09-29 19:05:41,617 INFO core: Event loop thread started, running loop forever
2026-09-29 19:05:41,918 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 19:05:41,925 INFO core: _init_accounts coroutine started
2026-09-29 19:05:41,925 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 19:05:41,932 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 19:10:13,332 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 19:15:15,549 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-29 19:15:15,550 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-29 19:15:15,564 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 19:20:33,840 INFO core: Event loop thread started, running loop forever
2026-09-29 19:20:34,147 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 19:20:34,163 INFO core: _init_accounts coroutine started
2026-09-29 19:20:34,163 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 19:20:34,175 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 19:25:43,679 INFO core: Event loop thread started, running loop forever
2026-09-29 19:25:43,981 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 19:25:43,986 INFO core: _init_accounts coroutine started
2026-09-29 19:25:43,987 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 19:25:43,993 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 19:30:09,043 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 19:35:16,400 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-29 19:35:16,400 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-29 19:35:16,400 WARNING core: ensure_llm_schema failed: cannot schedule new futures after shutdown
2026-09-29 19:35:16,401 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-29 19:35:16,401 WARNING core: ensure_pair_schema failed: cannot schedule new futures after shutdown
2026-09-29 19:35:16,401 INFO core: _init_accounts_inner: reloading LLM config
2026-09-29 19:35:47,043 INFO core: Event loop thread started, running loop forever
2026-09-29 19:35:47,344 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 19:35:47,352 INFO core: _init_accounts coroutine started
2026-09-29 19:35:47,353 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 19:35:47,356 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 19:40:10,616 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-29 19:40:10,617 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-29 19:40:10,618 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-29 19:40:10,619 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 19:45:21,324 INFO core: Event loop thread started, running loop forever
2026-09-29 19:45:21,625 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 19:45:21,630 INFO core: _init_accounts coroutine started
2026-09-29 19:45:21,630 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 19:45:21,637 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 19:50:43,767 INFO core: Event loop thread started, running loop forever
2026-09-29 19:50:44,069 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 19:50:44,072 INFO core: _init_accounts coroutine started
2026-09-29 19:50:44,072 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 19:50:44,081 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 19:55:26,260 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-29 19:55:26,261 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 19:55:26,261 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-29 20:00:33,413 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-29 20:00:41,845 INFO core: Event loop thread started, running loop forever
2026-09-29 20:00:42,149 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 20:00:42,158 INFO core: _init_accounts coroutine started
2026-09-29 20:00:42,159 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 20:00:42,163 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 20:05:48,812 INFO core: Event loop thread started, running loop forever
2026-09-29 20:05:49,113 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 20:05:49,121 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 20:10:45,117 INFO core: _init_accounts coroutine started
2026-09-29 20:10:45,118 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 20:10:45,123 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-29 20:10:45,124 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-29 20:10:45,125 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-29 20:10:45,125 INFO core: _init_accounts_inner: reloading LLM config
2026-09-29 20:10:45,136 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 20:15:51,943 INFO core: Event loop thread started, running loop forever
2026-09-29 20:15:52,247 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 20:15:52,252 INFO core: _init_accounts coroutine started
2026-09-29 20:15:52,254 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 20:15:52,263 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 20:20:46,744 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 20:25:32,080 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 20:30:12,321 INFO app: Retrying account initialization (clients=0 but authorized accounts in DB)
2026-09-29 20:30:12,322 INFO core: _init_accounts coroutine started
2026-09-29 20:30:12,322 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 20:30:12,343 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 20:35:22,958 INFO core: Event loop thread started, running loop forever
2026-09-29 20:35:23,259 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 20:35:23,265 INFO core: _init_accounts coroutine started
2026-09-29 20:35:23,266 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 20:35:23,271 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 20:40:36,991 INFO core: Event loop thread started, running loop forever
2026-09-29 20:40:37,293 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 20:40:37,297 INFO core: _init_accounts coroutine started
2026-09-29 20:40:37,301 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 20:40:37,303 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 20:45:04,374 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-09-29 20:45:41,932 INFO core: Event loop thread started, running loop forever
2026-09-29 20:45:42,233 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 20:45:42,237 INFO core: _init_accounts coroutine started
2026-09-29 20:45:42,237 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 20:45:42,243 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 20:50:39,375 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-29 20:50:39,375 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-29 20:50:39,377 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-29 20:50:39,380 INFO core: _init_accounts_inner: reloading LLM config
2026-09-29 20:50:39,388 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 20:55:15,547 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 21:00:14,917 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 21:05:33,829 INFO core: Event loop thread started, running loop forever
2026-09-29 21:05:34,132 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 21:05:34,135 INFO core: _init_accounts coroutine started
2026-09-29 21:05:34,136 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 21:05:34,146 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-29 21:05:34,147 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-29 21:05:34,150 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-29 21:05:34,151 INFO core: _init_accounts_inner: reloading LLM config
2026-09-29 21:05:34,154 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 21:10:22,692 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-09-29 21:10:22,692 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-09-29 21:10:22,695 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 21:10:22,699 INFO core: Account 2: connecting to Telegram via 91.108.56.178...
2026-09-29 21:10:22,700 INFO telethon.network.mtprotosender: Connecting to 91.108.56.178:443/TcpAbridged...
2026-09-29 21:15:08,946 WARNING telethon.network.mtprotosender: Attempt 1 at connecting failed: TimeoutError: 
2026-09-29 21:15:08,946 WARNING core: Account 2: connect timed out after 35s
2026-09-29 21:15:08,947 INFO telethon.network.mtprotosender: Disconnecting from 91.108.56.178:443/TcpAbridged...
2026-09-29 21:15:08,947 INFO telethon.network.mtprotosender: Disconnection from 91.108.56.178:443/TcpAbridged complete!
2026-09-29 21:15:08,948 INFO telethon.network.mtprotosender: Not disconnecting (already have no connection)
2026-09-29 21:15:08,950 INFO core: Account 2: connecting to Telegram via 91.108.56.181...
2026-09-29 21:15:08,950 INFO telethon.network.mtprotosender: Connecting to 91.108.56.181:443/TcpAbridged...
2026-09-29 21:15:08,966 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 21:20:15,415 WARNING telethon.network.mtprotosender: Attempt 1 at connecting failed: TimeoutError: 
2026-09-29 21:20:15,416 WARNING core: Account 2: connect timed out after 35s
2026-09-29 21:20:15,416 INFO telethon.network.mtprotosender: Disconnecting from 91.108.56.181:443/TcpAbridged...
2026-09-29 21:20:15,416 INFO telethon.network.mtprotosender: Disconnection from 91.108.56.181:443/TcpAbridged complete!
2026-09-29 21:20:15,417 INFO telethon.network.mtprotosender: Not disconnecting (already have no connection)
2026-09-29 21:20:15,418 INFO core: Account 2: connecting to Telegram via 91.108.56.182...
2026-09-29 21:20:15,418 INFO telethon.network.mtprotosender: Connecting to 91.108.56.182:443/TcpAbridged...
2026-09-29 21:20:33,615 INFO core: Event loop thread started, running loop forever
2026-09-29 21:20:33,925 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 21:20:33,932 INFO core: _init_accounts coroutine started
2026-09-29 21:20:33,933 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 21:20:33,958 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 21:25:52,658 INFO core: Event loop thread started, running loop forever
2026-09-29 21:25:52,959 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 21:25:52,964 INFO core: _init_accounts coroutine started
2026-09-29 21:25:52,965 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 21:25:52,986 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-29 21:25:52,986 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-29 21:25:52,987 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-29 21:25:52,989 INFO core: _init_accounts_inner: reloading LLM config
2026-09-29 21:25:52,993 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 21:30:06,540 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 21:35:21,617 INFO core: Event loop thread started, running loop forever
2026-09-29 21:35:21,918 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 21:35:21,927 INFO core: _init_accounts coroutine started
2026-09-29 21:35:21,927 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 21:35:21,935 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 21:40:16,500 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 21:45:35,591 INFO core: Event loop thread started, running loop forever
2026-09-29 21:45:35,891 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 21:45:35,896 INFO core: _init_accounts coroutine started
2026-09-29 21:45:35,897 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 21:45:35,903 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 21:50:33,817 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 21:55:40,491 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-29 21:55:40,505 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-29 21:55:40,714 INFO core: Event loop thread started, running loop forever
2026-09-29 21:55:41,015 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 21:55:41,026 INFO core: _init_accounts coroutine started
2026-09-29 21:55:41,028 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 21:55:41,041 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 22:00:48,542 ERROR core: _init_accounts failed: cannot schedule new futures after interpreter shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 173, in submit
    raise RuntimeError('cannot schedule new futures after '
                       'interpreter shutdown')
RuntimeError: cannot schedule new futures after interpreter shutdown
2026-09-29 22:00:55,760 INFO core: Event loop thread started, running loop forever
2026-09-29 22:00:56,070 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 22:00:56,077 INFO core: _init_accounts coroutine started
2026-09-29 22:00:56,077 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 22:00:56,100 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 22:05:26,684 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 22:05:26,685 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-29 22:05:26,685 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-29 22:10:32,231 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 22:15:38,398 WARNING core: ensure_llm_schema failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-09-29 22:15:38,398 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-29 22:15:38,398 WARNING core: ensure_pair_schema failed: cannot schedule new futures after shutdown
2026-09-29 22:15:38,399 INFO core: _init_accounts_inner: reloading LLM config
2026-09-29 22:15:38,399 WARNING core: LLM config load failed: cannot schedule new futures after shutdown
2026-09-29 22:15:38,399 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-09-29 22:15:38,399 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 180, in _init_accounts_inner
    await self._start_account_client(acct["id"])
  File "/home/wovewbge/quill.nx.kg/core.py", line 236, in _start_account_client
    session_str = await self._run_db(self.db.get_account_session, account_id)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-09-29 22:15:44,262 INFO core: Event loop thread started, running loop forever
2026-09-29 22:15:44,563 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 22:15:44,566 INFO core: _init_accounts coroutine started
2026-09-29 22:15:44,568 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 22:15:44,579 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 22:20:07,855 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 22:25:16,977 INFO core: Event loop thread started, running loop forever
2026-09-29 22:25:17,279 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 22:25:17,284 INFO core: _init_accounts coroutine started
2026-09-29 22:25:17,285 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 22:25:17,291 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 22:30:44,505 INFO core: Event loop thread started, running loop forever
2026-09-29 22:30:44,806 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 22:30:44,809 INFO core: _init_accounts coroutine started
2026-09-29 22:30:44,810 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 22:30:44,817 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 22:35:40,241 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 22:40:10,820 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-29 22:40:10,820 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-29 22:40:10,822 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-29 22:40:10,828 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 22:45:06,101 INFO core: _init_accounts_inner: reloading LLM config
2026-09-29 22:45:06,107 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 22:50:11,925 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 22:50:11,930 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-09-29 22:50:11,931 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-09-29 22:55:35,860 INFO core: Event loop thread started, running loop forever
2026-09-29 22:55:36,161 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 22:55:36,168 INFO core: _init_accounts coroutine started
2026-09-29 22:55:36,168 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 22:55:36,174 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 23:00:16,632 INFO core: Event loop thread started, running loop forever
2026-09-29 23:00:16,933 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 23:00:16,938 INFO core: _init_accounts coroutine started
2026-09-29 23:00:16,938 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 23:00:16,946 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 23:05:22,458 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-09-29 23:05:31,569 INFO core: Event loop thread started, running loop forever
2026-09-29 23:05:31,870 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 23:05:31,873 INFO core: _init_accounts coroutine started
2026-09-29 23:05:31,874 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 23:05:31,887 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 23:05:31,891 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-29 23:05:31,892 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-29 23:05:31,893 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-29 23:05:31,894 INFO core: _init_accounts_inner: reloading LLM config
2026-09-29 23:10:19,697 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 23:15:25,496 INFO core: Event loop thread started, running loop forever
2026-09-29 23:15:25,797 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 23:15:25,800 INFO core: _init_accounts coroutine started
2026-09-29 23:15:25,803 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 23:15:25,815 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 23:20:32,455 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-09-29 23:20:34,982 INFO core: Event loop thread started, running loop forever
2026-09-29 23:20:35,285 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 23:20:35,298 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 23:25:17,730 INFO core: _init_accounts coroutine started
2026-09-29 23:25:17,731 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 23:25:17,772 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 23:30:23,545 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-09-29 23:30:51,084 INFO core: Event loop thread started, running loop forever
2026-09-29 23:30:51,385 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 23:30:51,390 INFO core: _init_accounts coroutine started
2026-09-29 23:30:51,390 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 23:30:51,395 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 23:35:37,354 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 23:40:19,022 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 23:40:19,022 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-29 23:40:19,023 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-29 23:45:39,172 INFO core: Event loop thread started, running loop forever
2026-09-29 23:45:39,473 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-29 23:45:39,477 INFO core: _init_accounts coroutine started
2026-09-29 23:45:39,477 INFO core: _init_accounts_inner: starting DB migrations
2026-09-29 23:45:39,495 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-29 23:45:39,496 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-29 23:45:39,496 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-29 23:45:39,498 INFO core: _init_accounts_inner: reloading LLM config
2026-09-29 23:45:39,510 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-09-29 23:45:39,510 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-09-29 23:45:39,511 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 23:50:22,874 INFO core: Account 2: connecting to Telegram via 91.108.56.178...
2026-09-29 23:50:22,878 INFO core: status() clients=0 connected=False forwarding=False
2026-09-29 23:50:22,880 INFO telethon.network.mtprotosender: Connecting to 91.108.56.178:443/TcpAbridged...
2026-09-29 23:55:16,020 WARNING telethon.network.mtprotosender: Attempt 1 at connecting failed: TimeoutError: 
2026-09-29 23:55:16,020 WARNING core: Account 2: connect timed out after 35s
2026-09-29 23:55:16,021 INFO telethon.network.mtprotosender: Disconnecting from 91.108.56.178:443/TcpAbridged...
2026-09-29 23:55:16,022 INFO telethon.network.mtprotosender: Disconnection from 91.108.56.178:443/TcpAbridged complete!
2026-09-29 23:55:16,022 INFO telethon.network.mtprotosender: Not disconnecting (already have no connection)
2026-09-29 23:55:16,023 INFO core: Account 2: connecting to Telegram via 91.108.56.181...
2026-09-29 23:55:16,024 INFO telethon.network.mtprotosender: Connecting to 91.108.56.181:443/TcpAbridged...
2026-09-29 23:55:16,032 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 00:00:21,574 WARNING telethon.network.mtprotosender: Attempt 1 at connecting failed: TimeoutError: 
2026-09-30 00:00:21,575 WARNING core: Account 2: connect timed out after 35s
2026-09-30 00:00:21,576 INFO telethon.network.mtprotosender: Disconnecting from 91.108.56.181:443/TcpAbridged...
2026-09-30 00:00:21,576 INFO telethon.network.mtprotosender: Disconnection from 91.108.56.181:443/TcpAbridged complete!
2026-09-30 00:00:21,577 INFO telethon.network.mtprotosender: Not disconnecting (already have no connection)
2026-09-30 00:00:21,578 INFO core: Account 2: connecting to Telegram via 91.108.56.182...
2026-09-30 00:00:21,579 INFO telethon.network.mtprotosender: Connecting to 91.108.56.182:443/TcpAbridged...
2026-09-30 00:00:21,585 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 00:05:27,425 WARNING telethon.network.mtprotosender: Attempt 1 at connecting failed: TimeoutError: 
2026-09-30 00:05:27,426 WARNING core: Account 2: connect timed out after 35s
2026-09-30 00:05:27,426 INFO telethon.network.mtprotosender: Disconnecting from 91.108.56.182:443/TcpAbridged...
2026-09-30 00:05:27,426 INFO telethon.network.mtprotosender: Disconnection from 91.108.56.182:443/TcpAbridged complete!
2026-09-30 00:05:27,427 INFO telethon.network.mtprotosender: Not disconnecting (already have no connection)
2026-09-30 00:05:41,704 INFO core: Event loop thread started, running loop forever
2026-09-30 00:05:42,011 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 00:05:42,028 INFO core: _init_accounts coroutine started
2026-09-30 00:05:42,028 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 00:05:42,050 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 00:10:48,612 INFO core: Event loop thread started, running loop forever
2026-09-30 00:10:48,915 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 00:10:48,919 INFO core: _init_accounts coroutine started
2026-09-30 00:10:48,923 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 00:10:48,929 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 00:15:23,957 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 126, in _init_accounts_inner
    accounts = await self._run_db(self.db.get_accounts)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 540, in get_accounts
    with self._conn() as conn:
         ~~~~~~~~~~^^
  File "/opt/alt/python313/lib64/python3.13/contextlib.py", line 141, in __enter__
    return next(self.gen)
  File "/home/wovewbge/quill.nx.kg/db.py", line 59, in _conn
    conn = _pool.connect()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 448, in connect
    return _ConnectionFairy._checkout(self)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 1272, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 712, in checkout
    rec = pool._do_get()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/impl.py", line 178, in _do_get
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/impl.py", line 176, in _do_get
    return self._create_connection()
           ~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection
    return _ConnectionRecord(self)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 674, in __init__
    self.__connect()
    ~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 900, in __connect
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 896, in __connect
    self.dbapi_connection = connection = pool._invoke_creator(self)
                                         ~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 361, in <lambda>
    return lambda rec: creator_fn()
                       ~~~~~~~~~~^^
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-09-30 00:15:23,968 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 00:20:25,202 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 00:25:40,718 INFO core: Event loop thread started, running loop forever
2026-09-30 00:25:41,020 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 00:25:41,023 INFO core: _init_accounts coroutine started
2026-09-30 00:25:41,025 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 00:25:41,033 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 00:25:41,037 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-30 00:25:41,037 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-30 00:30:38,816 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-30 00:30:38,823 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 00:35:16,997 INFO core: _init_accounts_inner: reloading LLM config
2026-09-30 00:35:17,001 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 00:40:48,793 INFO core: Event loop thread started, running loop forever
2026-09-30 00:40:49,095 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 00:40:49,098 INFO core: _init_accounts coroutine started
2026-09-30 00:40:49,099 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 00:40:49,115 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 00:45:07,173 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-30 00:45:07,174 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-30 00:45:07,177 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-30 00:45:07,179 INFO core: _init_accounts_inner: reloading LLM config
2026-09-30 00:45:07,182 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 00:50:19,326 INFO core: Event loop thread started, running loop forever
2026-09-30 00:50:19,627 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 00:50:19,632 INFO core: _init_accounts coroutine started
2026-09-30 00:50:19,633 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 00:50:19,642 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 00:55:19,001 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-30 00:55:19,001 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 00:55:19,001 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-30 01:00:29,732 INFO core: Event loop thread started, running loop forever
2026-09-30 01:00:30,033 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 01:00:30,043 INFO core: _init_accounts coroutine started
2026-09-30 01:00:30,044 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 01:00:30,053 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 01:00:30,067 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-30 01:00:30,067 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-30 01:05:36,437 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-30 01:05:36,438 WARNING core: ensure_pair_schema failed: cannot schedule new futures after shutdown
2026-09-30 01:05:36,438 INFO core: _init_accounts_inner: reloading LLM config
2026-09-30 01:05:36,438 WARNING core: LLM config load failed: cannot schedule new futures after shutdown
2026-09-30 01:05:36,438 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-09-30 01:05:45,961 INFO core: Event loop thread started, running loop forever
2026-09-30 01:05:46,262 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 01:05:46,266 INFO core: _init_accounts coroutine started
2026-09-30 01:05:46,268 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 01:05:46,276 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 01:05:46,277 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-30 01:05:46,278 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-30 01:10:11,459 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-30 01:10:11,463 INFO core: _init_accounts_inner: reloading LLM config
2026-09-30 01:10:11,477 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-09-30 01:10:11,477 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-09-30 01:10:11,483 INFO core: Account 2: connecting to Telegram via 91.108.56.178...
2026-09-30 01:10:11,484 INFO telethon.network.mtprotosender: Connecting to 91.108.56.178:443/TcpAbridged...
2026-09-30 01:10:11,491 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 01:15:04,400 WARNING telethon.network.mtprotosender: Attempt 1 at connecting failed: TimeoutError: 
2026-09-30 01:15:04,401 WARNING core: Account 2: connect timed out after 35s
2026-09-30 01:15:04,402 INFO telethon.network.mtprotosender: Disconnecting from 91.108.56.178:443/TcpAbridged...
2026-09-30 01:15:04,402 INFO telethon.network.mtprotosender: Disconnection from 91.108.56.178:443/TcpAbridged complete!
2026-09-30 01:15:04,403 INFO telethon.network.mtprotosender: Not disconnecting (already have no connection)
2026-09-30 01:15:04,404 INFO core: Account 2: connecting to Telegram via 91.108.56.181...
2026-09-30 01:15:04,404 INFO telethon.network.mtprotosender: Connecting to 91.108.56.181:443/TcpAbridged...
2026-09-30 01:15:38,474 INFO core: Event loop thread started, running loop forever
2026-09-30 01:15:38,776 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 01:15:38,780 INFO core: _init_accounts coroutine started
2026-09-30 01:15:38,781 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 01:15:38,788 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 01:20:12,423 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 01:25:21,693 INFO core: Event loop thread started, running loop forever
2026-09-30 01:25:21,994 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 01:25:22,000 INFO core: _init_accounts coroutine started
2026-09-30 01:25:22,001 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 01:25:22,009 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 01:30:12,134 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-09-30 01:30:12,150 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 01:35:22,569 INFO core: Event loop thread started, running loop forever
2026-09-30 01:35:22,871 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 01:35:22,879 INFO core: _init_accounts coroutine started
2026-09-30 01:35:22,879 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 01:35:22,888 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 01:40:50,905 INFO core: Event loop thread started, running loop forever
2026-09-30 01:40:51,206 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 01:40:51,210 INFO core: _init_accounts coroutine started
2026-09-30 01:40:51,213 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 01:40:51,219 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 01:45:27,786 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-30 01:45:27,786 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-30 01:45:27,787 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-30 01:45:27,789 INFO core: _init_accounts_inner: reloading LLM config
2026-09-30 01:45:27,808 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 01:50:22,976 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 01:55:17,087 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 02:00:53,669 INFO core: Event loop thread started, running loop forever
2026-09-30 02:00:53,970 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 02:00:53,973 INFO core: _init_accounts coroutine started
2026-09-30 02:00:53,975 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 02:00:53,982 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 02:05:43,424 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-30 02:05:43,439 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-30 02:05:43,439 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 02:10:15,184 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 02:15:18,756 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-30 02:15:18,776 INFO core: _init_accounts_inner: reloading LLM config
2026-09-30 02:15:18,809 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 02:20:45,414 INFO core: Event loop thread started, running loop forever
2026-09-30 02:20:45,715 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 02:20:45,718 INFO core: _init_accounts coroutine started
2026-09-30 02:20:45,720 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 02:20:45,733 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 02:25:50,003 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 02:25:50,004 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-30 02:30:31,044 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-30 02:30:31,065 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-30 02:30:31,070 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 02:35:38,468 INFO core: _init_accounts_inner: reloading LLM config
2026-09-30 02:35:38,482 WARNING core: LLM config load failed: cannot schedule new futures after shutdown
2026-09-30 02:35:38,483 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-09-30 02:35:38,483 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 180, in _init_accounts_inner
    await self._start_account_client(acct["id"])
  File "/home/wovewbge/quill.nx.kg/core.py", line 236, in _start_account_client
    session_str = await self._run_db(self.db.get_account_session, account_id)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-09-30 02:35:52,678 INFO core: Event loop thread started, running loop forever
2026-09-30 02:35:52,983 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 02:35:52,987 INFO core: _init_accounts coroutine started
2026-09-30 02:35:52,989 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 02:35:53,012 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 02:40:49,332 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-30 02:40:49,333 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-30 02:40:49,339 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-30 02:40:49,345 INFO core: _init_accounts_inner: reloading LLM config
2026-09-30 02:40:49,391 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 02:45:46,004 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-09-30 02:45:46,005 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-09-30 02:45:46,007 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 02:50:30,737 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 02:55:37,701 INFO core: Event loop thread started, running loop forever
2026-09-30 02:55:38,005 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 02:55:38,013 INFO core: _init_accounts coroutine started
2026-09-30 02:55:38,013 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 02:55:38,052 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 03:00:33,892 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 03:05:39,634 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 149, in _init_accounts_inner
    await self._run_db(self.db.migrate_legacy_session)
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 687, in migrate_legacy_session
    with self._conn() as conn:
         ~~~~~~~~~~^^
  File "/opt/alt/python313/lib64/python3.13/contextlib.py", line 141, in __enter__
    return next(self.gen)
  File "/home/wovewbge/quill.nx.kg/db.py", line 59, in _conn
    conn = _pool.connect()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 448, in connect
    return _ConnectionFairy._checkout(self)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 1272, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 717, in checkout
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 715, in checkout
    dbapi_connection = rec.get_connection()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 866, in get_connection
    self.__connect()
    ~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 900, in __connect
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 896, in __connect
    self.dbapi_connection = connection = pool._invoke_creator(self)
                                         ~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 361, in <lambda>
    return lambda rec: creator_fn()
                       ~~~~~~~~~~^^
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-09-30 03:05:56,248 INFO core: Event loop thread started, running loop forever
2026-09-30 03:05:56,552 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 03:05:56,561 INFO core: _init_accounts coroutine started
2026-09-30 03:05:56,561 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 03:05:56,591 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-30 03:05:56,591 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-30 03:05:56,616 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 03:10:28,893 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-30 03:10:28,897 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 03:15:34,416 INFO core: _init_accounts_inner: reloading LLM config
2026-09-30 03:15:55,781 INFO core: Event loop thread started, running loop forever
2026-09-30 03:15:56,084 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 03:15:56,089 INFO core: _init_accounts coroutine started
2026-09-30 03:15:56,090 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 03:15:56,099 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 03:20:13,906 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 03:25:20,500 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-09-30 03:25:24,572 INFO core: Event loop thread started, running loop forever
2026-09-30 03:25:24,874 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 03:25:24,880 INFO core: _init_accounts coroutine started
2026-09-30 03:25:24,880 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 03:25:24,900 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 03:30:50,621 INFO core: Event loop thread started, running loop forever
2026-09-30 03:30:50,922 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 03:30:50,925 INFO core: _init_accounts coroutine started
2026-09-30 03:30:50,926 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 03:30:50,946 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 03:35:40,034 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 03:40:14,212 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 149, in _init_accounts_inner
    await self._run_db(self.db.migrate_legacy_session)
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 687, in migrate_legacy_session
    with self._conn() as conn:
         ~~~~~~~~~~^^
  File "/opt/alt/python313/lib64/python3.13/contextlib.py", line 141, in __enter__
    return next(self.gen)
  File "/home/wovewbge/quill.nx.kg/db.py", line 59, in _conn
    conn = _pool.connect()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 448, in connect
    return _ConnectionFairy._checkout(self)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 1272, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 717, in checkout
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 715, in checkout
    dbapi_connection = rec.get_connection()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 866, in get_connection
    self.__connect()
    ~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 900, in __connect
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 896, in __connect
    self.dbapi_connection = connection = pool._invoke_creator(self)
                                         ~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 361, in <lambda>
    return lambda rec: creator_fn()
                       ~~~~~~~~~~^^
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-09-30 03:40:14,220 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 03:45:12,070 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 03:50:44,299 INFO core: Event loop thread started, running loop forever
2026-09-30 03:50:44,600 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 03:50:44,603 INFO core: _init_accounts coroutine started
2026-09-30 03:50:44,604 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 03:50:44,618 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-30 03:50:44,619 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-30 03:50:44,619 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 03:55:22,169 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-30 03:55:22,176 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 04:00:22,350 INFO core: _init_accounts_inner: reloading LLM config
2026-09-30 04:00:22,366 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 04:05:27,115 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-09-30 04:05:27,116 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-09-30 04:05:27,119 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 04:05:27,124 INFO core: Account 2: connecting to Telegram via 91.108.56.178...
2026-09-30 04:05:27,126 INFO telethon.network.mtprotosender: Connecting to 91.108.56.178:443/TcpAbridged...
2026-09-30 04:10:34,432 WARNING telethon.network.mtprotosender: Attempt 1 at connecting failed: TimeoutError: 
2026-09-30 04:10:34,434 WARNING core: Account 2: connect timed out after 35s
2026-09-30 04:10:34,435 INFO telethon.network.mtprotosender: Disconnecting from 91.108.56.178:443/TcpAbridged...
2026-09-30 04:10:47,359 INFO core: Event loop thread started, running loop forever
2026-09-30 04:10:47,660 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 04:10:47,666 INFO core: _init_accounts coroutine started
2026-09-30 04:10:47,667 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 04:10:47,676 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 04:15:19,214 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-30 04:15:19,215 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-30 04:15:19,217 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-30 04:15:19,217 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 04:15:19,218 INFO core: _init_accounts_inner: reloading LLM config
2026-09-30 04:20:26,457 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-09-30 04:20:26,458 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-09-30 04:20:26,458 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 180, in _init_accounts_inner
    await self._start_account_client(acct["id"])
  File "/home/wovewbge/quill.nx.kg/core.py", line 236, in _start_account_client
    session_str = await self._run_db(self.db.get_account_session, account_id)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-09-30 04:20:30,897 INFO core: Event loop thread started, running loop forever
2026-09-30 04:20:31,199 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 04:20:31,203 INFO core: _init_accounts coroutine started
2026-09-30 04:20:31,206 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 04:20:31,213 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 04:25:09,837 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 04:30:36,034 INFO core: Event loop thread started, running loop forever
2026-09-30 04:30:36,338 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 04:30:36,341 INFO core: _init_accounts coroutine started
2026-09-30 04:30:36,349 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 04:30:36,350 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 04:35:43,437 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-09-30 04:35:49,920 INFO core: Event loop thread started, running loop forever
2026-09-30 04:35:50,222 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 04:35:50,226 INFO core: _init_accounts coroutine started
2026-09-30 04:35:50,227 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 04:35:50,241 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 04:40:24,565 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 04:45:30,752 INFO core: Event loop thread started, running loop forever
2026-09-30 04:45:31,053 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 04:45:31,056 INFO core: _init_accounts coroutine started
2026-09-30 04:45:31,057 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 04:45:31,064 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 04:45:31,068 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-30 04:45:31,068 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-30 04:45:31,069 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-30 04:50:46,773 INFO core: Event loop thread started, running loop forever
2026-09-30 04:50:47,080 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 04:50:47,086 INFO core: _init_accounts coroutine started
2026-09-30 04:50:47,087 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 04:50:47,106 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-30 04:50:47,106 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-30 04:50:47,107 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-30 04:50:47,108 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 04:50:47,109 INFO core: _init_accounts_inner: reloading LLM config
2026-09-30 04:55:50,910 INFO core: Event loop thread started, running loop forever
2026-09-30 04:55:51,211 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 04:55:51,214 INFO core: _init_accounts coroutine started
2026-09-30 04:55:51,216 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 04:55:51,224 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 05:00:19,093 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 05:05:31,877 INFO core: Event loop thread started, running loop forever
2026-09-30 05:05:32,179 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 05:05:32,183 INFO core: _init_accounts coroutine started
2026-09-30 05:05:32,186 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 05:05:32,203 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 05:10:38,463 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 149, in _init_accounts_inner
    await self._run_db(self.db.migrate_legacy_session)
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-09-30 05:10:41,292 INFO core: Event loop thread started, running loop forever
2026-09-30 05:10:41,594 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 05:10:41,600 INFO core: _init_accounts coroutine started
2026-09-30 05:10:41,600 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 05:10:41,606 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 05:15:40,585 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-30 05:15:40,586 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-30 05:15:40,589 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-30 05:15:40,592 INFO core: _init_accounts_inner: reloading LLM config
2026-09-30 05:15:40,607 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 05:15:40,610 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-09-30 05:20:35,452 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-09-30 05:20:35,468 INFO core: Account 2: connecting to Telegram via 91.108.56.178...
2026-09-30 05:20:35,469 INFO telethon.network.mtprotosender: Connecting to 91.108.56.178:443/TcpAbridged...
2026-09-30 05:20:35,475 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 05:25:32,158 WARNING telethon.network.mtprotosender: Attempt 1 at connecting failed: TimeoutError: 
2026-09-30 05:25:32,160 WARNING core: Account 2: connect timed out after 35s
2026-09-30 05:25:32,161 INFO telethon.network.mtprotosender: Disconnecting from 91.108.56.178:443/TcpAbridged...
2026-09-30 05:25:32,161 INFO telethon.network.mtprotosender: Disconnection from 91.108.56.178:443/TcpAbridged complete!
2026-09-30 05:25:32,162 INFO telethon.network.mtprotosender: Not disconnecting (already have no connection)
2026-09-30 05:25:32,163 INFO core: Account 2: connecting to Telegram via 91.108.56.181...
2026-09-30 05:25:32,163 INFO telethon.network.mtprotosender: Connecting to 91.108.56.181:443/TcpAbridged...
2026-09-30 05:25:32,213 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 05:30:24,291 WARNING telethon.network.mtprotosender: Attempt 1 at connecting failed: TimeoutError: 
2026-09-30 05:30:24,291 WARNING core: Account 2: connect timed out after 35s
2026-09-30 05:30:24,292 INFO telethon.network.mtprotosender: Disconnecting from 91.108.56.181:443/TcpAbridged...
2026-09-30 05:30:24,292 INFO telethon.network.mtprotosender: Disconnection from 91.108.56.181:443/TcpAbridged complete!
2026-09-30 05:30:24,292 INFO telethon.network.mtprotosender: Not disconnecting (already have no connection)
2026-09-30 05:30:24,294 INFO core: Account 2: connecting to Telegram via 91.108.56.182...
2026-09-30 05:30:24,294 INFO telethon.network.mtprotosender: Connecting to 91.108.56.182:443/TcpAbridged...
2026-09-30 05:30:24,301 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 05:35:12,527 WARNING telethon.network.mtprotosender: Attempt 1 at connecting failed: TimeoutError: 
2026-09-30 05:35:12,527 WARNING core: Account 2: connect timed out after 35s
2026-09-30 05:35:12,535 INFO telethon.network.mtprotosender: Disconnecting from 91.108.56.182:443/TcpAbridged...
2026-09-30 05:35:12,536 INFO telethon.network.mtprotosender: Disconnection from 91.108.56.182:443/TcpAbridged complete!
2026-09-30 05:35:12,537 INFO telethon.network.mtprotosender: Not disconnecting (already have no connection)
2026-09-30 05:35:12,538 INFO core: Account 2: connecting to Telegram via 91.108.56.186...
2026-09-30 05:35:12,539 INFO telethon.network.mtprotosender: Connecting to 91.108.56.186:443/TcpAbridged...
2026-09-30 05:35:12,542 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 05:40:19,418 WARNING telethon.network.mtprotosender: Attempt 1 at connecting failed: TimeoutError: 
2026-09-30 05:40:27,398 INFO core: Event loop thread started, running loop forever
2026-09-30 05:40:27,702 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 05:40:27,706 INFO core: _init_accounts coroutine started
2026-09-30 05:40:27,707 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 05:40:27,727 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 05:45:54,559 INFO core: Event loop thread started, running loop forever
2026-09-30 05:45:54,862 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 05:45:54,865 INFO core: _init_accounts coroutine started
2026-09-30 05:45:54,866 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 05:45:54,870 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 05:50:45,195 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 05:50:45,196 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-30 05:50:45,199 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-30 05:55:12,500 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 06:00:47,041 INFO core: Event loop thread started, running loop forever
2026-09-30 06:00:47,342 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 06:00:47,346 INFO core: _init_accounts coroutine started
2026-09-30 06:00:47,347 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 06:00:47,353 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 06:05:30,577 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-30 06:05:30,578 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-30 06:05:30,579 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-30 06:05:30,581 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 06:10:13,736 INFO core: _init_accounts_inner: reloading LLM config
2026-09-30 06:10:13,747 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 06:15:19,540 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-09-30 06:15:19,541 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-09-30 06:15:19,541 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 180, in _init_accounts_inner
    await self._start_account_client(acct["id"])
  File "/home/wovewbge/quill.nx.kg/core.py", line 236, in _start_account_client
    session_str = await self._run_db(self.db.get_account_session, account_id)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-09-30 06:15:22,855 INFO core: Event loop thread started, running loop forever
2026-09-30 06:15:23,156 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 06:15:23,160 INFO core: _init_accounts coroutine started
2026-09-30 06:15:23,160 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 06:15:23,167 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 06:20:29,398 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-09-30 06:20:39,157 INFO core: Event loop thread started, running loop forever
2026-09-30 06:20:39,460 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 06:20:39,472 INFO core: _init_accounts coroutine started
2026-09-30 06:20:39,472 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 06:20:39,473 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 06:25:26,977 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 06:30:31,271 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 06:35:13,545 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 06:40:26,153 INFO core: Event loop thread started, running loop forever
2026-09-30 06:40:26,454 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 06:40:26,457 INFO core: _init_accounts coroutine started
2026-09-30 06:40:26,459 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 06:40:26,465 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 06:45:09,416 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-09-30 06:45:09,423 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 06:50:16,250 INFO core: Event loop thread started, running loop forever
2026-09-30 06:50:16,551 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 06:50:16,559 INFO core: _init_accounts coroutine started
2026-09-30 06:50:16,560 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 06:50:16,567 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 06:55:23,421 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-30 06:55:23,430 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-30 06:55:23,430 WARNING core: ensure_llm_schema failed: cannot schedule new futures after shutdown
2026-09-30 06:55:23,430 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-30 06:55:23,431 WARNING core: ensure_pair_schema failed: cannot schedule new futures after shutdown
2026-09-30 06:55:23,431 INFO core: _init_accounts_inner: reloading LLM config
2026-09-30 06:55:23,431 WARNING core: LLM config load failed: cannot schedule new futures after shutdown
2026-09-30 06:55:23,431 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-09-30 06:55:23,431 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 180, in _init_accounts_inner
    await self._start_account_client(acct["id"])
  File "/home/wovewbge/quill.nx.kg/core.py", line 236, in _start_account_client
    session_str = await self._run_db(self.db.get_account_session, account_id)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-09-30 06:55:41,524 INFO core: Event loop thread started, running loop forever
2026-09-30 06:55:41,825 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 06:55:41,835 INFO core: _init_accounts coroutine started
2026-09-30 06:55:41,836 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 06:55:41,842 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 07:00:17,203 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 07:05:20,379 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-30 07:05:20,379 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-30 07:05:20,382 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-30 07:05:20,384 INFO core: _init_accounts_inner: reloading LLM config
2026-09-30 07:05:20,393 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 07:10:18,939 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 07:15:23,495 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 07:20:30,459 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-09-30 07:20:53,571 INFO core: Event loop thread started, running loop forever
2026-09-30 07:20:53,872 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 07:20:53,881 INFO core: _init_accounts coroutine started
2026-09-30 07:20:53,881 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 07:20:53,889 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 07:25:27,021 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-09-30 07:25:27,074 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 07:30:49,570 INFO core: Event loop thread started, running loop forever
2026-09-30 07:30:49,871 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 07:30:49,875 INFO core: _init_accounts coroutine started
2026-09-30 07:30:49,877 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 07:30:49,883 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 07:35:26,020 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-30 07:35:26,021 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-30 07:35:26,023 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-30 07:35:26,025 INFO core: _init_accounts_inner: reloading LLM config
2026-09-30 07:35:26,056 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 07:40:06,800 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-09-30 07:40:06,800 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-09-30 07:40:06,806 INFO core: Account 2: connecting to Telegram via 91.108.56.178...
2026-09-30 07:40:06,807 INFO telethon.network.mtprotosender: Connecting to 91.108.56.178:443/TcpAbridged...
2026-09-30 07:40:06,816 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 07:45:13,433 WARNING telethon.network.mtprotosender: Attempt 1 at connecting failed: TimeoutError: 
2026-09-30 07:45:13,433 WARNING core: Account 2: connect timed out after 35s
2026-09-30 07:45:13,434 INFO telethon.network.mtprotosender: Disconnecting from 91.108.56.178:443/TcpAbridged...
2026-09-30 07:45:13,434 INFO telethon.network.mtprotosender: Disconnection from 91.108.56.178:443/TcpAbridged complete!
2026-09-30 07:45:13,435 INFO telethon.network.mtprotosender: Not disconnecting (already have no connection)
2026-09-30 07:45:13,435 INFO core: Account 2: connecting to Telegram via 91.108.56.181...
2026-09-30 07:45:13,436 INFO telethon.network.mtprotosender: Connecting to 91.108.56.181:443/TcpAbridged...
2026-09-30 07:45:27,524 INFO core: Event loop thread started, running loop forever
2026-09-30 07:45:27,825 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 07:45:27,828 INFO core: _init_accounts coroutine started
2026-09-30 07:45:27,828 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 07:45:27,843 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 07:50:38,780 INFO core: Event loop thread started, running loop forever
2026-09-30 07:50:39,087 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 07:50:39,093 INFO core: _init_accounts coroutine started
2026-09-30 07:50:39,094 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 07:50:39,103 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 07:55:04,795 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-30 07:55:04,803 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-30 07:55:04,809 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 08:00:05,430 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-30 08:00:05,462 INFO core: _init_accounts_inner: reloading LLM config
2026-09-30 08:00:05,462 WARNING core: LLM config load failed: cannot schedule new futures after shutdown
2026-09-30 08:00:05,463 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-09-30 08:00:05,463 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 180, in _init_accounts_inner
    await self._start_account_client(acct["id"])
  File "/home/wovewbge/quill.nx.kg/core.py", line 236, in _start_account_client
    session_str = await self._run_db(self.db.get_account_session, account_id)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-09-30 08:00:54,383 INFO core: Event loop thread started, running loop forever
2026-09-30 08:00:54,688 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 08:00:54,691 INFO core: _init_accounts coroutine started
2026-09-30 08:00:54,692 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 08:00:54,696 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 08:05:15,270 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 08:10:26,377 INFO core: Event loop thread started, running loop forever
2026-09-30 08:10:26,684 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 08:10:26,688 INFO core: _init_accounts coroutine started
2026-09-30 08:10:26,690 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 08:10:26,697 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 08:15:49,053 INFO core: Event loop thread started, running loop forever
2026-09-30 08:15:49,355 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 08:15:49,358 INFO core: _init_accounts coroutine started
2026-09-30 08:15:49,360 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 08:15:49,369 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 08:20:38,295 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-30 08:20:38,296 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-30 08:20:38,303 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 08:25:10,981 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-30 08:25:11,019 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 08:30:17,503 INFO core: _init_accounts_inner: reloading LLM config
2026-09-30 08:30:35,404 INFO core: Event loop thread started, running loop forever
2026-09-30 08:30:35,713 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 08:30:35,718 INFO core: _init_accounts coroutine started
2026-09-30 08:30:35,719 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 08:30:35,775 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 08:35:06,453 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 08:40:13,469 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-30 08:40:13,471 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-30 08:40:13,471 WARNING core: ensure_llm_schema failed: cannot schedule new futures after shutdown
2026-09-30 08:40:13,472 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-30 08:40:13,472 WARNING core: ensure_pair_schema failed: cannot schedule new futures after shutdown
2026-09-30 08:40:13,472 INFO core: _init_accounts_inner: reloading LLM config
2026-09-30 08:40:13,472 WARNING core: LLM config load failed: cannot schedule new futures after shutdown
2026-09-30 08:40:13,472 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-09-30 08:40:22,353 INFO core: Event loop thread started, running loop forever
2026-09-30 08:40:22,655 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 08:40:22,661 INFO core: _init_accounts coroutine started
2026-09-30 08:40:22,663 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 08:40:22,666 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 08:45:09,250 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 08:50:16,450 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-09-30 08:50:20,286 INFO core: Event loop thread started, running loop forever
2026-09-30 08:50:20,588 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 08:50:20,594 INFO core: _init_accounts coroutine started
2026-09-30 08:50:20,595 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 08:50:20,602 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 08:55:13,717 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 09:00:24,074 INFO core: Event loop thread started, running loop forever
2026-09-30 09:00:24,379 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 09:00:24,381 INFO core: _init_accounts coroutine started
2026-09-30 09:00:24,384 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 09:00:24,392 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 09:05:31,428 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-09-30 09:05:51,373 INFO core: Event loop thread started, running loop forever
2026-09-30 09:05:51,675 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 09:05:51,679 INFO core: _init_accounts coroutine started
2026-09-30 09:05:51,681 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 09:05:51,687 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 09:10:37,462 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-30 09:10:37,462 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-30 09:10:37,463 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-30 09:10:37,464 INFO core: _init_accounts_inner: reloading LLM config
2026-09-30 09:10:37,485 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 09:15:32,756 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 09:20:08,214 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-09-30 09:20:08,215 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-09-30 09:20:08,220 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 09:25:28,561 INFO core: Event loop thread started, running loop forever
2026-09-30 09:25:28,863 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 09:25:28,867 INFO core: _init_accounts coroutine started
2026-09-30 09:25:28,869 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 09:25:28,880 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 09:30:53,763 INFO core: Event loop thread started, running loop forever
2026-09-30 09:30:54,064 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 09:30:54,067 INFO core: _init_accounts coroutine started
2026-09-30 09:30:54,067 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 09:30:54,076 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 09:35:43,417 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 09:40:14,958 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 149, in _init_accounts_inner
    await self._run_db(self.db.migrate_legacy_session)
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 687, in migrate_legacy_session
    with self._conn() as conn:
         ~~~~~~~~~~^^
  File "/opt/alt/python313/lib64/python3.13/contextlib.py", line 141, in __enter__
    return next(self.gen)
  File "/home/wovewbge/quill.nx.kg/db.py", line 59, in _conn
    conn = _pool.connect()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 448, in connect
    return _ConnectionFairy._checkout(self)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 1272, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 717, in checkout
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 715, in checkout
    dbapi_connection = rec.get_connection()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 866, in get_connection
    self.__connect()
    ~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 900, in __connect
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 896, in __connect
    self.dbapi_connection = connection = pool._invoke_creator(self)
                                         ~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 361, in <lambda>
    return lambda rec: creator_fn()
                       ~~~~~~~~~~^^
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-09-30 09:40:14,969 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 09:45:21,722 INFO core: Event loop thread started, running loop forever
2026-09-30 09:45:22,023 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 09:45:22,026 INFO core: _init_accounts coroutine started
2026-09-30 09:45:22,029 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 09:45:22,041 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 09:50:17,212 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-09-30 09:50:17,225 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 09:55:35,511 INFO core: Event loop thread started, running loop forever
2026-09-30 09:55:35,811 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 09:55:35,814 INFO core: _init_accounts coroutine started
2026-09-30 09:55:35,817 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 09:55:35,823 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 10:00:42,434 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-30 10:00:43,861 INFO core: Event loop thread started, running loop forever
2026-09-30 10:00:44,162 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 10:00:44,168 INFO core: _init_accounts coroutine started
2026-09-30 10:00:44,168 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 10:00:44,176 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 10:05:43,044 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-30 10:05:43,045 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-30 10:05:43,048 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-30 10:05:43,050 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 10:05:43,051 INFO core: _init_accounts_inner: reloading LLM config
2026-09-30 10:10:46,277 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 10:15:03,445 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-09-30 10:15:03,446 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-09-30 10:15:03,447 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 180, in _init_accounts_inner
    await self._start_account_client(acct["id"])
  File "/home/wovewbge/quill.nx.kg/core.py", line 236, in _start_account_client
    session_str = await self._run_db(self.db.get_account_session, account_id)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-09-30 10:15:30,786 INFO core: Event loop thread started, running loop forever
2026-09-30 10:15:31,088 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 10:15:31,093 INFO core: _init_accounts coroutine started
2026-09-30 10:15:31,095 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 10:15:31,096 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 10:20:49,098 INFO core: Event loop thread started, running loop forever
2026-09-30 10:20:49,399 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 10:20:49,403 INFO core: _init_accounts coroutine started
2026-09-30 10:20:49,404 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 10:20:49,413 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 10:25:10,596 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 10:30:12,290 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-30 10:30:12,291 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-30 10:30:12,294 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-30 10:30:12,296 INFO core: _init_accounts_inner: reloading LLM config
2026-09-30 10:30:12,298 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 10:35:52,825 INFO core: Event loop thread started, running loop forever
2026-09-30 10:35:53,127 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 10:35:53,130 INFO core: _init_accounts coroutine started
2026-09-30 10:35:53,132 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 10:35:53,147 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 10:40:45,877 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-30 10:40:45,877 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-30 10:40:45,881 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-30 10:40:45,884 INFO core: _init_accounts_inner: reloading LLM config
2026-09-30 10:40:45,890 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 10:45:23,444 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 10:50:09,409 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-09-30 10:50:09,411 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-09-30 10:50:09,419 INFO core: Account 2: connecting to Telegram via 91.108.56.178...
2026-09-30 10:50:09,421 INFO telethon.network.mtprotosender: Connecting to 91.108.56.178:443/TcpAbridged...
2026-09-30 10:50:09,424 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 10:55:14,789 WARNING telethon.network.mtprotosender: Attempt 1 at connecting failed: TimeoutError: 
2026-09-30 10:55:14,789 WARNING core: Account 2: connect timed out after 35s
2026-09-30 10:55:14,790 INFO telethon.network.mtprotosender: Disconnecting from 91.108.56.178:443/TcpAbridged...
2026-09-30 10:55:14,790 INFO telethon.network.mtprotosender: Disconnection from 91.108.56.178:443/TcpAbridged complete!
2026-09-30 10:55:14,791 INFO telethon.network.mtprotosender: Not disconnecting (already have no connection)
2026-09-30 10:55:14,792 INFO core: Account 2: connecting to Telegram via 91.108.56.181...
2026-09-30 10:55:14,792 INFO telethon.network.mtprotosender: Connecting to 91.108.56.181:443/TcpAbridged...
2026-09-30 10:55:14,796 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 11:00:46,392 INFO core: Event loop thread started, running loop forever
2026-09-30 11:00:46,693 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 11:00:46,698 INFO core: _init_accounts coroutine started
2026-09-30 11:00:46,698 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 11:00:46,707 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 11:05:52,770 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-30 11:05:52,770 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-30 11:05:52,776 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-30 11:05:52,779 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 11:10:20,718 INFO core: _init_accounts_inner: reloading LLM config
2026-09-30 11:10:20,731 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 11:15:26,482 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-09-30 11:15:43,702 INFO core: Event loop thread started, running loop forever
2026-09-30 11:15:44,004 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 11:15:44,016 INFO core: _init_accounts coroutine started
2026-09-30 11:15:44,016 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 11:15:44,022 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-30 11:15:44,022 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-30 11:15:44,023 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-30 11:15:44,024 INFO core: _init_accounts_inner: reloading LLM config
2026-09-30 11:15:44,031 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 11:20:36,339 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 11:20:36,340 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-09-30 11:20:36,340 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-09-30 11:25:10,898 INFO core: Account 2: connecting to Telegram via 91.108.56.178...
2026-09-30 11:25:10,900 INFO telethon.network.mtprotosender: Connecting to 91.108.56.178:443/TcpAbridged...
2026-09-30 11:25:10,908 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 11:30:17,418 WARNING telethon.network.mtprotosender: Attempt 1 at connecting failed: TimeoutError: 
2026-09-30 11:30:17,418 WARNING core: Account 2: connect timed out after 35s
2026-09-30 11:30:17,419 INFO telethon.network.mtprotosender: Disconnecting from 91.108.56.178:443/TcpAbridged...
2026-09-30 11:30:17,419 INFO telethon.network.mtprotosender: Disconnection from 91.108.56.178:443/TcpAbridged complete!
2026-09-30 11:30:17,420 INFO telethon.network.mtprotosender: Not disconnecting (already have no connection)
2026-09-30 11:30:17,421 INFO core: Account 2: connecting to Telegram via 91.108.56.181...
2026-09-30 11:30:17,421 INFO telethon.network.mtprotosender: Connecting to 91.108.56.181:443/TcpAbridged...
2026-09-30 11:30:51,573 INFO core: Event loop thread started, running loop forever
2026-09-30 11:30:51,875 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 11:30:51,878 INFO core: _init_accounts coroutine started
2026-09-30 11:30:51,879 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 11:30:51,885 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 11:35:53,314 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 11:40:49,733 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-30 11:40:49,733 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-30 11:40:49,741 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 11:45:14,983 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-30 11:45:14,988 INFO core: _init_accounts_inner: reloading LLM config
2026-09-30 11:45:14,989 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 11:50:43,073 INFO core: Event loop thread started, running loop forever
2026-09-30 11:50:43,374 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 11:50:43,378 INFO core: _init_accounts coroutine started
2026-09-30 11:50:43,380 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 11:50:43,388 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 11:55:33,744 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 12:00:54,148 INFO core: Event loop thread started, running loop forever
2026-09-30 12:00:54,449 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 12:00:54,455 INFO core: _init_accounts coroutine started
2026-09-30 12:00:54,456 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 12:00:54,470 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 12:05:52,199 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 12:10:32,505 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-30 12:10:32,505 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-30 12:10:32,510 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-30 12:10:32,512 INFO core: _init_accounts_inner: reloading LLM config
2026-09-30 12:10:32,522 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 12:15:18,679 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 12:20:14,091 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 12:25:16,907 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 12:25:16,908 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-09-30 12:30:05,449 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-09-30 12:30:22,502 INFO core: Event loop thread started, running loop forever
2026-09-30 12:30:22,803 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 12:30:22,807 INFO core: _init_accounts coroutine started
2026-09-30 12:30:22,808 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 12:30:22,814 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 12:35:06,666 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 126, in _init_accounts_inner
    accounts = await self._run_db(self.db.get_accounts)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 540, in get_accounts
    with self._conn() as conn:
         ~~~~~~~~~~^^
  File "/opt/alt/python313/lib64/python3.13/contextlib.py", line 141, in __enter__
    return next(self.gen)
  File "/home/wovewbge/quill.nx.kg/db.py", line 59, in _conn
    conn = _pool.connect()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 448, in connect
    return _ConnectionFairy._checkout(self)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 1272, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 712, in checkout
    rec = pool._do_get()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/impl.py", line 178, in _do_get
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/impl.py", line 176, in _do_get
    return self._create_connection()
           ~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection
    return _ConnectionRecord(self)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 674, in __init__
    self.__connect()
    ~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 900, in __connect
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 896, in __connect
    self.dbapi_connection = connection = pool._invoke_creator(self)
                                         ~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 361, in <lambda>
    return lambda rec: creator_fn()
                       ~~~~~~~~~~^^
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-09-30 12:35:06,699 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 12:40:28,170 INFO core: Event loop thread started, running loop forever
2026-09-30 12:40:28,471 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 12:40:28,478 INFO core: _init_accounts coroutine started
2026-09-30 12:40:28,478 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 12:40:28,482 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 12:45:28,258 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-30 12:45:28,259 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-30 12:45:28,260 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-30 12:45:28,263 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 12:45:28,263 INFO core: _init_accounts_inner: reloading LLM config
2026-09-30 12:50:12,947 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 12:55:46,825 INFO core: Event loop thread started, running loop forever
2026-09-30 12:55:47,127 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 12:55:47,131 INFO core: _init_accounts coroutine started
2026-09-30 12:55:47,134 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 12:55:47,147 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 13:00:44,601 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 13:05:20,943 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-09-30 13:05:20,956 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 13:10:13,902 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 13:15:42,289 INFO core: Event loop thread started, running loop forever
2026-09-30 13:15:42,590 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 13:15:42,594 INFO core: _init_accounts coroutine started
2026-09-30 13:15:42,597 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 13:15:42,601 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 13:20:45,469 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 126, in _init_accounts_inner
    accounts = await self._run_db(self.db.get_accounts)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 540, in get_accounts
    with self._conn() as conn:
         ~~~~~~~~~~^^
  File "/opt/alt/python313/lib64/python3.13/contextlib.py", line 141, in __enter__
    return next(self.gen)
  File "/home/wovewbge/quill.nx.kg/db.py", line 59, in _conn
    conn = _pool.connect()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 448, in connect
    return _ConnectionFairy._checkout(self)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 1272, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 712, in checkout
    rec = pool._do_get()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/impl.py", line 178, in _do_get
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/impl.py", line 176, in _do_get
    return self._create_connection()
           ~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection
    return _ConnectionRecord(self)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 674, in __init__
    self.__connect()
    ~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 900, in __connect
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 896, in __connect
    self.dbapi_connection = connection = pool._invoke_creator(self)
                                         ~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 361, in <lambda>
    return lambda rec: creator_fn()
                       ~~~~~~~~~~^^
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-09-30 13:20:45,477 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 13:25:11,487 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 13:30:19,571 INFO core: Event loop thread started, running loop forever
2026-09-30 13:30:19,876 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 13:30:19,883 INFO core: _init_accounts coroutine started
2026-09-30 13:30:19,883 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 13:30:19,897 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 13:35:25,482 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-09-30 13:35:48,862 INFO core: Event loop thread started, running loop forever
2026-09-30 13:35:49,163 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 13:35:49,166 INFO core: _init_accounts coroutine started
2026-09-30 13:35:49,167 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 13:35:49,175 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 13:40:39,598 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 13:45:34,595 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-30 13:45:34,596 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-30 13:45:34,598 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 13:50:40,302 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 13:55:38,442 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-30 13:55:38,455 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 14:00:08,328 INFO core: _init_accounts_inner: reloading LLM config
2026-09-30 14:00:08,411 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 14:05:52,686 INFO core: Event loop thread started, running loop forever
2026-09-30 14:05:52,987 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 14:05:52,992 INFO core: _init_accounts coroutine started
2026-09-30 14:05:52,993 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 14:05:53,000 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 14:10:48,099 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 14:15:41,656 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-30 14:15:41,656 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-30 14:15:41,673 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-30 14:15:41,677 INFO core: _init_accounts_inner: reloading LLM config
2026-09-30 14:15:41,678 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 14:20:19,949 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 14:25:41,376 INFO core: Event loop thread started, running loop forever
2026-09-30 14:25:41,677 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 14:25:41,684 INFO core: _init_accounts coroutine started
2026-09-30 14:25:41,684 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 14:25:41,690 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 14:25:41,692 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-30 14:25:41,695 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-30 14:30:46,470 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-30 14:30:46,471 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 14:35:04,180 INFO core: _init_accounts_inner: reloading LLM config
2026-09-30 14:35:04,207 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 14:40:10,372 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 14:45:05,411 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-09-30 14:45:05,412 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-09-30 14:45:16,656 INFO core: Event loop thread started, running loop forever
2026-09-30 14:45:16,964 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 14:45:16,967 INFO core: _init_accounts coroutine started
2026-09-30 14:45:16,967 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 14:45:16,978 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 14:50:30,441 INFO core: Event loop thread started, running loop forever
2026-09-30 14:50:30,743 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 14:50:30,748 INFO core: _init_accounts coroutine started
2026-09-30 14:50:30,748 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 14:50:30,758 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 14:55:21,652 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 15:00:37,700 INFO core: Event loop thread started, running loop forever
2026-09-30 15:00:38,000 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 15:00:38,008 INFO core: _init_accounts coroutine started
2026-09-30 15:00:38,008 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 15:00:38,021 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 15:05:38,115 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 15:10:50,840 INFO core: Event loop thread started, running loop forever
2026-09-30 15:10:51,142 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 15:10:51,343 INFO core: _init_accounts coroutine started
2026-09-30 15:10:51,345 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 15:10:51,365 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 15:10:51,368 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-30 15:15:13,274 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-30 15:15:13,293 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-30 15:15:13,279 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 15:20:35,282 INFO core: Event loop thread started, running loop forever
2026-09-30 15:20:35,586 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 15:20:35,592 INFO core: _init_accounts coroutine started
2026-09-30 15:20:35,592 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 15:20:35,625 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 15:25:33,367 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-30 15:25:33,368 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-30 15:25:33,391 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-30 15:25:33,399 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 15:30:10,666 INFO core: _init_accounts_inner: reloading LLM config
2026-09-30 15:30:10,687 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 15:35:12,764 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 15:40:05,713 WARNING core: LLM config load failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-09-30 15:40:05,715 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-09-30 15:40:05,721 INFO core: Account 2: connecting to Telegram via 91.108.56.178...
2026-09-30 15:40:05,722 INFO telethon.network.mtprotosender: Connecting to 91.108.56.178:443/TcpAbridged...
2026-09-30 15:40:05,782 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 15:45:11,475 WARNING telethon.network.mtprotosender: Attempt 1 at connecting failed: TimeoutError: 
2026-09-30 15:45:11,475 WARNING core: Account 2: connect timed out after 35s
2026-09-30 15:45:11,476 INFO telethon.network.mtprotosender: Disconnecting from 91.108.56.178:443/TcpAbridged...
2026-09-30 15:45:11,476 INFO telethon.network.mtprotosender: Disconnection from 91.108.56.178:443/TcpAbridged complete!
2026-09-30 15:45:11,477 INFO telethon.network.mtprotosender: Not disconnecting (already have no connection)
2026-09-30 15:45:11,478 INFO core: Account 2: connecting to Telegram via 91.108.56.181...
2026-09-30 15:45:11,479 INFO telethon.network.mtprotosender: Connecting to 91.108.56.181:443/TcpAbridged...
2026-09-30 15:45:21,379 INFO core: Event loop thread started, running loop forever
2026-09-30 15:45:21,680 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 15:45:21,684 INFO core: _init_accounts coroutine started
2026-09-30 15:45:21,686 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 15:45:21,706 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-30 15:45:21,706 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-30 15:45:21,708 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-30 15:45:21,709 INFO core: _init_accounts_inner: reloading LLM config
2026-09-30 15:45:21,730 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 15:50:17,483 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-09-30 15:50:17,484 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-09-30 15:50:17,492 INFO core: Account 2: connecting to Telegram via 91.108.56.178...
2026-09-30 15:50:17,494 INFO telethon.network.mtprotosender: Connecting to 91.108.56.178:443/TcpAbridged...
2026-09-30 15:50:17,496 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 15:55:24,400 WARNING telethon.network.mtprotosender: Attempt 1 at connecting failed: TimeoutError: 
2026-09-30 15:55:24,401 WARNING core: Account 2: connect timed out after 35s
2026-09-30 15:55:24,402 INFO telethon.network.mtprotosender: Disconnecting from 91.108.56.178:443/TcpAbridged...
2026-09-30 15:55:24,402 INFO telethon.network.mtprotosender: Disconnection from 91.108.56.178:443/TcpAbridged complete!
2026-09-30 15:55:24,403 INFO telethon.network.mtprotosender: Not disconnecting (already have no connection)
2026-09-30 15:55:24,405 INFO core: Account 2: connecting to Telegram via 91.108.56.181...
2026-09-30 15:55:24,405 INFO telethon.network.mtprotosender: Connecting to 91.108.56.181:443/TcpAbridged...
2026-09-30 15:55:47,883 INFO core: Event loop thread started, running loop forever
2026-09-30 15:55:48,184 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 15:55:48,190 INFO core: _init_accounts coroutine started
2026-09-30 15:55:48,191 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 15:55:48,200 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 16:00:12,677 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-30 16:00:12,677 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-30 16:00:12,679 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-30 16:00:12,681 INFO core: _init_accounts_inner: reloading LLM config
2026-09-30 16:00:12,683 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 16:05:19,462 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-09-30 16:05:19,462 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-09-30 16:05:30,719 INFO core: Event loop thread started, running loop forever
2026-09-30 16:05:31,021 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 16:05:31,030 INFO core: _init_accounts coroutine started
2026-09-30 16:05:31,031 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 16:05:31,043 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 16:10:40,153 INFO core: Event loop thread started, running loop forever
2026-09-30 16:10:40,454 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 16:10:40,457 INFO core: _init_accounts coroutine started
2026-09-30 16:10:40,459 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 16:10:40,466 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 16:15:38,349 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-30 16:15:38,349 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-30 16:15:38,350 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-30 16:15:38,351 INFO core: _init_accounts_inner: reloading LLM config
2026-09-30 16:15:38,362 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-09-30 16:15:38,363 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-09-30 16:15:38,369 INFO core: Account 2: connecting to Telegram via 91.108.56.178...
2026-09-30 16:15:38,370 INFO telethon.network.mtprotosender: Connecting to 91.108.56.178:443/TcpAbridged...
2026-09-30 16:15:38,376 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 16:20:45,527 WARNING telethon.network.mtprotosender: Attempt 1 at connecting failed: TimeoutError: 
2026-09-30 16:20:45,527 WARNING core: Account 2: connect timed out after 35s
2026-09-30 16:20:45,528 INFO telethon.network.mtprotosender: Disconnecting from 91.108.56.178:443/TcpAbridged...
2026-09-30 16:20:45,528 INFO telethon.network.mtprotosender: Disconnection from 91.108.56.178:443/TcpAbridged complete!
2026-09-30 16:20:45,529 INFO telethon.network.mtprotosender: Not disconnecting (already have no connection)
2026-09-30 16:20:45,530 INFO core: Account 2: connecting to Telegram via 91.108.56.181...
2026-09-30 16:20:45,530 INFO telethon.network.mtprotosender: Connecting to 91.108.56.181:443/TcpAbridged...
2026-09-30 16:20:54,157 INFO core: Event loop thread started, running loop forever
2026-09-30 16:20:54,461 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 16:20:54,471 INFO core: _init_accounts coroutine started
2026-09-30 16:20:54,471 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 16:20:54,483 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 16:25:36,631 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-09-30 16:25:36,675 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 16:30:31,641 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 16:35:29,040 INFO app: Retrying account initialization (clients=0 but authorized accounts in DB)
2026-09-30 16:35:29,047 INFO core: _init_accounts coroutine started
2026-09-30 16:35:29,047 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 16:35:29,057 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 16:40:13,113 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-30 16:40:13,113 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-30 16:40:13,115 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-30 16:40:13,116 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 16:45:20,417 INFO core: _init_accounts_inner: reloading LLM config
2026-09-30 16:45:25,234 INFO core: Event loop thread started, running loop forever
2026-09-30 16:45:25,535 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 16:45:25,545 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 16:50:32,401 INFO core: _init_accounts coroutine started
2026-09-30 16:50:32,402 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 16:50:32,402 ERROR core: _init_accounts failed: cannot schedule new futures after interpreter shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 126, in _init_accounts_inner
    accounts = await self._run_db(self.db.get_accounts)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 173, in submit
    raise RuntimeError('cannot schedule new futures after '
                       'interpreter shutdown')
RuntimeError: cannot schedule new futures after interpreter shutdown
2026-09-30 16:50:51,994 INFO core: Event loop thread started, running loop forever
2026-09-30 16:50:52,295 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 16:50:52,300 INFO core: _init_accounts coroutine started
2026-09-30 16:50:52,301 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 16:50:52,305 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 16:55:04,189 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 16:55:04,190 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-30 17:00:11,436 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-30 17:00:11,450 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-30 17:00:11,450 WARNING core: ensure_pair_schema failed: cannot schedule new futures after shutdown
2026-09-30 17:00:11,451 INFO core: _init_accounts_inner: reloading LLM config
2026-09-30 17:00:11,451 WARNING core: LLM config load failed: cannot schedule new futures after shutdown
2026-09-30 17:00:11,451 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-09-30 17:00:11,451 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 180, in _init_accounts_inner
    await self._start_account_client(acct["id"])
  File "/home/wovewbge/quill.nx.kg/core.py", line 236, in _start_account_client
    session_str = await self._run_db(self.db.get_account_session, account_id)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-09-30 17:00:42,591 INFO core: Event loop thread started, running loop forever
2026-09-30 17:00:42,892 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 17:00:42,896 INFO core: _init_accounts coroutine started
2026-09-30 17:00:42,897 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 17:00:42,903 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 17:05:18,976 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-30 17:05:18,976 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-30 17:05:18,983 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 17:10:04,173 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-30 17:10:04,180 INFO core: _init_accounts_inner: reloading LLM config
2026-09-30 17:10:04,184 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 17:15:48,174 INFO core: Event loop thread started, running loop forever
2026-09-30 17:15:48,477 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 17:15:48,482 INFO core: _init_accounts coroutine started
2026-09-30 17:15:48,482 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 17:15:48,493 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 17:15:48,498 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-30 17:15:48,498 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-30 17:15:48,499 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-30 17:15:48,501 INFO core: _init_accounts_inner: reloading LLM config
2026-09-30 17:20:45,949 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 17:25:08,475 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 17:30:44,307 INFO core: Event loop thread started, running loop forever
2026-09-30 17:30:44,608 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 17:30:44,613 INFO core: _init_accounts coroutine started
2026-09-30 17:30:44,613 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 17:30:44,619 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 17:35:36,679 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-30 17:35:36,680 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 17:35:36,680 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-30 17:40:15,128 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-30 17:40:15,140 INFO core: _init_accounts_inner: reloading LLM config
2026-09-30 17:40:15,152 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 17:45:24,221 INFO core: Event loop thread started, running loop forever
2026-09-30 17:45:24,522 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 17:45:24,537 INFO core: _init_accounts coroutine started
2026-09-30 17:45:24,537 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 17:45:24,557 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-30 17:45:24,557 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-30 17:45:24,562 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-30 17:45:24,566 INFO core: _init_accounts_inner: reloading LLM config
2026-09-30 17:45:24,567 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 17:50:09,556 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 17:55:26,937 INFO core: Event loop thread started, running loop forever
2026-09-30 17:55:27,239 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 17:55:27,244 INFO core: _init_accounts coroutine started
2026-09-30 17:55:27,245 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 17:55:27,250 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 18:00:32,351 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 126, in _init_accounts_inner
    accounts = await self._run_db(self.db.get_accounts)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 540, in get_accounts
    with self._conn() as conn:
         ~~~~~~~~~~^^
  File "/opt/alt/python313/lib64/python3.13/contextlib.py", line 141, in __enter__
    return next(self.gen)
  File "/home/wovewbge/quill.nx.kg/db.py", line 59, in _conn
    conn = _pool.connect()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 448, in connect
    return _ConnectionFairy._checkout(self)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 1272, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 712, in checkout
    rec = pool._do_get()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/impl.py", line 178, in _do_get
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/impl.py", line 176, in _do_get
    return self._create_connection()
           ~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection
    return _ConnectionRecord(self)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 674, in __init__
    self.__connect()
    ~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 900, in __connect
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 896, in __connect
    self.dbapi_connection = connection = pool._invoke_creator(self)
                                         ~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 361, in <lambda>
    return lambda rec: creator_fn()
                       ~~~~~~~~~~^^
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-09-30 18:00:32,358 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 18:05:05,354 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 18:10:41,717 INFO core: Event loop thread started, running loop forever
2026-09-30 18:10:42,019 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 18:10:42,023 INFO core: _init_accounts coroutine started
2026-09-30 18:10:42,024 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 18:10:42,040 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 18:15:09,752 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 18:20:15,422 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-30 18:20:44,807 INFO core: Event loop thread started, running loop forever
2026-09-30 18:20:45,109 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 18:20:45,114 INFO core: _init_accounts coroutine started
2026-09-30 18:20:45,114 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 18:20:45,124 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 18:25:31,865 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 18:30:04,419 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-09-30 18:30:56,356 INFO core: Event loop thread started, running loop forever
2026-09-30 18:30:56,660 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 18:30:56,668 INFO core: _init_accounts coroutine started
2026-09-30 18:30:56,668 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 18:30:56,672 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 18:35:52,122 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 18:40:51,520 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-30 18:40:51,521 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-30 18:40:51,523 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 18:45:12,200 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-30 18:45:12,213 INFO core: _init_accounts_inner: reloading LLM config
2026-09-30 18:45:12,219 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 18:50:48,257 INFO core: Event loop thread started, running loop forever
2026-09-30 18:50:48,559 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 18:50:48,562 INFO core: _init_accounts coroutine started
2026-09-30 18:50:48,564 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 18:50:48,570 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 18:55:17,410 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 19:00:14,522 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-30 19:00:14,522 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-30 19:00:14,523 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 19:05:21,459 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-30 19:05:22,370 INFO core: Event loop thread started, running loop forever
2026-09-30 19:05:22,672 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 19:05:22,677 INFO core: _init_accounts coroutine started
2026-09-30 19:05:22,677 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 19:05:22,690 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 19:05:22,695 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-30 19:05:22,705 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-30 19:10:52,146 INFO core: Event loop thread started, running loop forever
2026-09-30 19:10:52,446 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 19:10:52,451 INFO core: _init_accounts coroutine started
2026-09-30 19:10:52,451 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 19:10:52,461 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-30 19:10:52,461 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-30 19:10:52,462 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-30 19:10:52,464 INFO core: _init_accounts_inner: reloading LLM config
2026-09-30 19:10:52,470 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 19:15:40,948 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 19:20:46,052 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 19:20:46,052 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-09-30 19:20:46,053 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-09-30 19:25:27,410 INFO core: Account 2: connecting to Telegram via 91.108.56.178...
2026-09-30 19:25:27,411 INFO telethon.network.mtprotosender: Connecting to 91.108.56.178:443/TcpAbridged...
2026-09-30 19:25:27,415 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 19:30:37,594 INFO core: Event loop thread started, running loop forever
2026-09-30 19:30:37,896 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 19:30:37,906 INFO core: _init_accounts coroutine started
2026-09-30 19:30:37,907 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 19:30:37,910 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 19:35:16,266 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 19:40:22,904 INFO core: Event loop thread started, running loop forever
2026-09-30 19:40:23,207 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 19:40:23,210 INFO core: _init_accounts coroutine started
2026-09-30 19:40:23,212 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 19:40:23,227 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 19:45:37,801 INFO core: Event loop thread started, running loop forever
2026-09-30 19:45:38,101 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 19:45:38,105 INFO core: _init_accounts coroutine started
2026-09-30 19:45:38,107 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 19:45:38,114 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 19:50:36,510 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 19:55:43,397 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-30 19:55:43,957 INFO core: Event loop thread started, running loop forever
2026-09-30 19:55:44,258 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 19:55:44,261 INFO core: _init_accounts coroutine started
2026-09-30 19:55:44,262 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 19:55:44,270 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 20:00:04,838 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-09-30 20:00:04,891 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 20:05:09,246 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 20:10:07,578 INFO app: Retrying account initialization (clients=0 but authorized accounts in DB)
2026-09-30 20:10:07,578 INFO core: _init_accounts coroutine started
2026-09-30 20:10:07,579 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 20:10:07,589 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 20:10:07,591 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-30 20:10:07,591 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-30 20:10:07,592 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-30 20:10:07,594 INFO core: _init_accounts_inner: reloading LLM config
2026-09-30 20:15:13,443 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-09-30 20:15:52,780 INFO core: Event loop thread started, running loop forever
2026-09-30 20:15:53,081 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 20:15:53,087 INFO core: _init_accounts coroutine started
2026-09-30 20:15:53,087 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 20:15:53,097 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-30 20:15:53,097 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-30 20:15:53,098 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-30 20:15:53,099 INFO core: _init_accounts_inner: reloading LLM config
2026-09-30 20:15:53,106 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 20:20:45,815 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 20:25:36,465 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 20:30:43,426 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-09-30 20:30:43,426 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-09-30 20:30:43,427 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 180, in _init_accounts_inner
    await self._start_account_client(acct["id"])
  File "/home/wovewbge/quill.nx.kg/core.py", line 236, in _start_account_client
    session_str = await self._run_db(self.db.get_account_session, account_id)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-09-30 20:30:53,876 INFO core: Event loop thread started, running loop forever
2026-09-30 20:30:54,177 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 20:30:54,187 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 20:35:42,791 INFO core: _init_accounts coroutine started
2026-09-30 20:35:42,793 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 20:35:42,803 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 20:40:24,299 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 126, in _init_accounts_inner
    accounts = await self._run_db(self.db.get_accounts)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 540, in get_accounts
    with self._conn() as conn:
         ~~~~~~~~~~^^
  File "/opt/alt/python313/lib64/python3.13/contextlib.py", line 141, in __enter__
    return next(self.gen)
  File "/home/wovewbge/quill.nx.kg/db.py", line 59, in _conn
    conn = _pool.connect()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 448, in connect
    return _ConnectionFairy._checkout(self)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 1272, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 712, in checkout
    rec = pool._do_get()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/impl.py", line 178, in _do_get
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/impl.py", line 176, in _do_get
    return self._create_connection()
           ~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection
    return _ConnectionRecord(self)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 674, in __init__
    self.__connect()
    ~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 900, in __connect
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 896, in __connect
    self.dbapi_connection = connection = pool._invoke_creator(self)
                                         ~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 361, in <lambda>
    return lambda rec: creator_fn()
                       ~~~~~~~~~~^^
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-09-30 20:40:24,322 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 20:45:22,413 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 20:50:46,909 INFO core: Event loop thread started, running loop forever
2026-09-30 20:50:47,210 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 20:50:47,216 INFO core: _init_accounts coroutine started
2026-09-30 20:50:47,217 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 20:50:47,223 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 20:55:15,552 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-30 20:55:15,552 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-30 20:55:15,554 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-30 20:55:15,556 INFO core: _init_accounts_inner: reloading LLM config
2026-09-30 20:55:15,556 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 21:00:29,272 INFO core: Event loop thread started, running loop forever
2026-09-30 21:00:29,573 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 21:00:29,576 INFO core: _init_accounts coroutine started
2026-09-30 21:00:29,579 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 21:00:29,583 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 21:05:32,979 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 21:10:38,414 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-09-30 21:10:41,284 INFO core: Event loop thread started, running loop forever
2026-09-30 21:10:41,585 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 21:10:41,589 INFO core: _init_accounts coroutine started
2026-09-30 21:10:41,590 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 21:10:41,600 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 21:10:41,601 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-30 21:10:41,601 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-30 21:15:48,382 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-30 21:15:48,531 WARNING core: ensure_pair_schema failed: cannot schedule new futures after shutdown
2026-09-30 21:15:48,531 INFO core: _init_accounts_inner: reloading LLM config
2026-09-30 21:15:48,531 WARNING core: LLM config load failed: cannot schedule new futures after shutdown
2026-09-30 21:15:48,531 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-09-30 21:15:48,531 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 180, in _init_accounts_inner
    await self._start_account_client(acct["id"])
  File "/home/wovewbge/quill.nx.kg/core.py", line 236, in _start_account_client
    session_str = await self._run_db(self.db.get_account_session, account_id)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-09-30 21:15:50,514 INFO core: Event loop thread started, running loop forever
2026-09-30 21:15:50,815 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 21:15:50,820 INFO core: _init_accounts coroutine started
2026-09-30 21:15:50,822 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 21:15:50,827 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 21:20:51,251 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 21:25:24,247 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-30 21:25:24,249 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-30 21:25:24,252 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 21:30:15,041 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-30 21:30:15,045 INFO core: _init_accounts_inner: reloading LLM config
2026-09-30 21:30:15,053 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 21:35:53,754 INFO core: Event loop thread started, running loop forever
2026-09-30 21:35:54,055 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 21:35:54,062 INFO core: _init_accounts coroutine started
2026-09-30 21:35:54,062 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 21:35:54,075 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-30 21:35:54,075 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-30 21:35:54,077 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-30 21:35:54,078 INFO core: _init_accounts_inner: reloading LLM config
2026-09-30 21:35:54,080 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 21:40:37,620 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 21:45:25,835 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 21:45:25,843 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-09-30 21:45:25,848 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-09-30 21:50:12,939 INFO core: Account 2: connecting to Telegram via 91.108.56.178...
2026-09-30 21:50:12,940 INFO telethon.network.mtprotosender: Connecting to 91.108.56.178:443/TcpAbridged...
2026-09-30 21:50:12,949 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 21:55:08,098 WARNING telethon.network.mtprotosender: Attempt 1 at connecting failed: TimeoutError: 
2026-09-30 21:55:08,099 WARNING core: Account 2: connect timed out after 35s
2026-09-30 21:55:08,100 INFO telethon.network.mtprotosender: Disconnecting from 91.108.56.178:443/TcpAbridged...
2026-09-30 21:55:08,100 INFO telethon.network.mtprotosender: Disconnection from 91.108.56.178:443/TcpAbridged complete!
2026-09-30 21:55:08,102 INFO telethon.network.mtprotosender: Not disconnecting (already have no connection)
2026-09-30 21:55:08,103 INFO core: Account 2: connecting to Telegram via 91.108.56.181...
2026-09-30 21:55:08,103 INFO telethon.network.mtprotosender: Connecting to 91.108.56.181:443/TcpAbridged...
2026-09-30 21:55:08,106 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 22:00:14,673 INFO core: Event loop thread started, running loop forever
2026-09-30 22:00:14,678 WARNING telethon.network.mtprotosender: Attempt 1 at connecting failed: TimeoutError: 
2026-09-30 22:00:14,679 WARNING core: Account 2: connect timed out after 35s
2026-09-30 22:00:14,679 INFO telethon.network.mtprotosender: Disconnecting from 91.108.56.181:443/TcpAbridged...
2026-09-30 22:00:14,680 INFO telethon.network.mtprotosender: Disconnection from 91.108.56.181:443/TcpAbridged complete!
2026-09-30 22:00:14,680 INFO telethon.network.mtprotosender: Not disconnecting (already have no connection)
2026-09-30 22:00:14,681 INFO core: Account 2: connecting to Telegram via 91.108.56.182...
2026-09-30 22:00:14,682 INFO telethon.network.mtprotosender: Connecting to 91.108.56.182:443/TcpAbridged...
2026-09-30 22:00:14,981 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 22:00:14,990 INFO core: _init_accounts coroutine started
2026-09-30 22:00:14,990 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 22:00:15,018 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 22:05:22,473 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-30 22:05:22,475 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-30 22:05:22,475 WARNING core: ensure_llm_schema failed: cannot schedule new futures after shutdown
2026-09-30 22:05:22,476 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-30 22:05:51,710 INFO core: Event loop thread started, running loop forever
2026-09-30 22:05:52,010 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 22:05:52,017 INFO core: _init_accounts coroutine started
2026-09-30 22:05:52,018 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 22:05:52,024 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 22:10:12,501 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-09-30 22:10:12,513 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 22:15:38,131 INFO core: Event loop thread started, running loop forever
2026-09-30 22:15:38,431 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 22:15:38,436 INFO core: _init_accounts coroutine started
2026-09-30 22:15:38,438 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 22:15:38,448 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 22:20:28,872 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-30 22:20:28,872 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-30 22:20:28,892 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 22:25:18,267 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-30 22:25:18,275 INFO core: _init_accounts_inner: reloading LLM config
2026-09-30 22:25:18,276 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 22:30:20,617 INFO core: Event loop thread started, running loop forever
2026-09-30 22:30:20,918 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 22:30:20,922 INFO core: _init_accounts coroutine started
2026-09-30 22:30:20,923 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 22:30:20,938 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 22:35:13,306 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 22:40:37,274 INFO core: Event loop thread started, running loop forever
2026-09-30 22:40:37,577 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 22:40:37,635 INFO core: _init_accounts coroutine started
2026-09-30 22:40:37,636 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 22:40:37,648 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 22:45:43,578 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-09-30 22:45:43,603 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 22:50:36,951 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 22:53:44,688 INFO app: Retrying account initialization (clients=0 but authorized accounts in DB)
2026-09-30 22:53:44,689 INFO core: _init_accounts coroutine started
2026-09-30 22:53:44,689 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 22:53:44,694 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 22:53:44,709 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-30 22:53:44,709 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-30 22:55:21,747 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-30 22:55:21,749 INFO core: _init_accounts_inner: reloading LLM config
2026-09-30 22:55:21,751 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 23:00:18,555 INFO core: Event loop thread started, running loop forever
2026-09-30 23:00:18,859 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 23:00:18,864 INFO core: _init_accounts coroutine started
2026-09-30 23:00:18,866 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 23:00:18,867 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 23:05:20,713 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 23:10:21,526 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 149, in _init_accounts_inner
    await self._run_db(self.db.migrate_legacy_session)
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 687, in migrate_legacy_session
    with self._conn() as conn:
         ~~~~~~~~~~^^
  File "/opt/alt/python313/lib64/python3.13/contextlib.py", line 141, in __enter__
    return next(self.gen)
  File "/home/wovewbge/quill.nx.kg/db.py", line 59, in _conn
    conn = _pool.connect()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 448, in connect
    return _ConnectionFairy._checkout(self)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 1272, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 717, in checkout
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 715, in checkout
    dbapi_connection = rec.get_connection()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 866, in get_connection
    self.__connect()
    ~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 900, in __connect
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 896, in __connect
    self.dbapi_connection = connection = pool._invoke_creator(self)
                                         ~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 361, in <lambda>
    return lambda rec: creator_fn()
                       ~~~~~~~~~~^^
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-09-30 23:10:21,542 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 23:15:22,657 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 23:20:43,058 INFO core: Event loop thread started, running loop forever
2026-09-30 23:20:43,359 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 23:20:43,364 INFO core: _init_accounts coroutine started
2026-09-30 23:20:43,364 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 23:20:43,374 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-30 23:20:43,375 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-30 23:20:43,375 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 23:20:43,377 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-30 23:25:09,072 INFO core: _init_accounts_inner: reloading LLM config
2026-09-30 23:25:09,102 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 23:30:55,613 INFO core: Event loop thread started, running loop forever
2026-09-30 23:30:55,915 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 23:30:55,927 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 23:35:15,912 INFO core: _init_accounts coroutine started
2026-09-30 23:35:15,912 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 23:35:15,926 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 23:35:15,926 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-09-30 23:35:15,926 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-09-30 23:40:18,968 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 23:40:18,969 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-09-30 23:45:07,142 INFO core: _init_accounts_inner: reloading LLM config
2026-09-30 23:45:07,146 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 23:50:52,575 INFO core: Event loop thread started, running loop forever
2026-09-30 23:50:52,877 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-09-30 23:50:52,882 INFO core: _init_accounts coroutine started
2026-09-30 23:50:52,883 INFO core: _init_accounts_inner: starting DB migrations
2026-09-30 23:50:52,893 INFO core: status() clients=0 connected=False forwarding=False
2026-09-30 23:55:33,687 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 00:00:41,502 INFO core: Event loop thread started, running loop forever
2026-10-01 00:00:41,805 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 00:00:41,811 INFO core: _init_accounts coroutine started
2026-10-01 00:00:41,811 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 00:00:41,815 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 00:05:38,110 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 126, in _init_accounts_inner
    accounts = await self._run_db(self.db.get_accounts)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 540, in get_accounts
    with self._conn() as conn:
         ~~~~~~~~~~^^
  File "/opt/alt/python313/lib64/python3.13/contextlib.py", line 141, in __enter__
    return next(self.gen)
  File "/home/wovewbge/quill.nx.kg/db.py", line 59, in _conn
    conn = _pool.connect()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 448, in connect
    return _ConnectionFairy._checkout(self)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 1272, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 712, in checkout
    rec = pool._do_get()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/impl.py", line 178, in _do_get
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/impl.py", line 176, in _do_get
    return self._create_connection()
           ~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection
    return _ConnectionRecord(self)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 674, in __init__
    self.__connect()
    ~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 900, in __connect
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 896, in __connect
    self.dbapi_connection = connection = pool._invoke_creator(self)
                                         ~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 361, in <lambda>
    return lambda rec: creator_fn()
                       ~~~~~~~~~~^^
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-10-01 00:05:38,118 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 00:10:12,817 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 00:15:39,962 INFO core: Event loop thread started, running loop forever
2026-10-01 00:15:40,264 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 00:15:40,270 INFO core: _init_accounts coroutine started
2026-10-01 00:15:40,271 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 00:15:40,276 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 00:20:11,845 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 00:20:11,845 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 00:20:11,846 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-01 00:20:11,848 INFO core: _init_accounts_inner: reloading LLM config
2026-10-01 00:20:11,863 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 00:25:46,678 INFO core: Event loop thread started, running loop forever
2026-10-01 00:25:46,979 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 00:25:46,991 INFO core: _init_accounts coroutine started
2026-10-01 00:25:46,992 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 00:25:47,003 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 00:25:47,003 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 00:25:47,004 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 00:25:47,004 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-01 00:25:47,017 INFO core: _init_accounts_inner: reloading LLM config
2026-10-01 00:30:53,568 INFO core: Event loop thread started, running loop forever
2026-10-01 00:30:53,869 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 00:30:53,880 INFO core: _init_accounts coroutine started
2026-10-01 00:30:53,880 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 00:30:53,886 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 00:35:26,327 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-10-01 00:35:26,341 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 00:40:30,983 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 00:45:10,737 INFO app: Retrying account initialization (clients=0 but authorized accounts in DB)
2026-10-01 00:45:10,750 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 00:50:06,877 INFO core: _init_accounts coroutine started
2026-10-01 00:50:06,878 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 00:50:06,904 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 00:55:30,365 INFO core: Event loop thread started, running loop forever
2026-10-01 00:55:30,667 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 00:55:30,672 INFO core: _init_accounts coroutine started
2026-10-01 00:55:30,673 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 00:55:30,682 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 01:00:37,456 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 01:00:37,456 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 01:00:37,459 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-01 01:00:37,460 INFO core: _init_accounts_inner: reloading LLM config
2026-10-01 01:00:37,461 WARNING core: LLM config load failed: cannot schedule new futures after shutdown
2026-10-01 01:00:37,461 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-10-01 01:00:55,051 INFO core: Event loop thread started, running loop forever
2026-10-01 01:00:55,354 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 01:00:55,358 INFO core: _init_accounts coroutine started
2026-10-01 01:00:55,359 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 01:00:55,367 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 01:05:22,812 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 01:05:22,813 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 01:05:22,815 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-01 01:05:22,817 INFO core: _init_accounts_inner: reloading LLM config
2026-10-01 01:05:22,818 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 01:10:54,842 INFO core: Event loop thread started, running loop forever
2026-10-01 01:10:55,143 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 01:10:55,147 INFO core: _init_accounts coroutine started
2026-10-01 01:10:55,148 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 01:10:55,214 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 01:15:07,358 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-10-01 01:15:18,264 INFO core: Event loop thread started, running loop forever
2026-10-01 01:15:18,565 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 01:15:18,568 INFO core: _init_accounts coroutine started
2026-10-01 01:15:18,569 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 01:15:18,577 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 01:20:31,291 INFO core: Event loop thread started, running loop forever
2026-10-01 01:20:31,592 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 01:20:31,596 INFO core: _init_accounts coroutine started
2026-10-01 01:20:31,597 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 01:20:31,605 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 01:25:38,463 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 149, in _init_accounts_inner
    await self._run_db(self.db.migrate_legacy_session)
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-10-01 01:25:48,657 INFO core: Event loop thread started, running loop forever
2026-10-01 01:25:48,958 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 01:25:48,964 INFO core: _init_accounts coroutine started
2026-10-01 01:25:48,970 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 01:25:48,971 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 01:30:54,472 ERROR core: _init_accounts failed: cannot schedule new futures after interpreter shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 126, in _init_accounts_inner
    accounts = await self._run_db(self.db.get_accounts)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 173, in submit
    raise RuntimeError('cannot schedule new futures after '
                       'interpreter shutdown')
RuntimeError: cannot schedule new futures after interpreter shutdown
2026-10-01 01:30:56,665 INFO core: Event loop thread started, running loop forever
2026-10-01 01:30:56,966 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 01:30:56,974 INFO core: _init_accounts coroutine started
2026-10-01 01:30:56,982 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 01:30:56,976 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 01:35:31,321 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 01:40:37,591 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-10-01 01:40:37,607 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 01:45:48,475 INFO core: Event loop thread started, running loop forever
2026-10-01 01:45:48,776 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 01:45:48,781 INFO core: _init_accounts coroutine started
2026-10-01 01:45:48,783 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 01:45:48,792 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 01:50:39,384 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 01:50:39,384 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 01:50:39,385 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 01:50:39,386 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-01 01:55:48,594 INFO core: Event loop thread started, running loop forever
2026-10-01 01:55:48,895 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 01:55:48,899 INFO core: _init_accounts coroutine started
2026-10-01 01:55:48,900 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 01:55:48,909 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 02:00:32,137 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 02:00:32,138 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 02:00:32,159 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 02:05:37,649 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 02:10:32,562 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-01 02:10:32,574 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 02:15:16,025 INFO core: _init_accounts_inner: reloading LLM config
2026-10-01 02:15:16,034 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 02:20:42,163 INFO core: Event loop thread started, running loop forever
2026-10-01 02:20:42,464 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 02:20:42,467 INFO core: _init_accounts coroutine started
2026-10-01 02:20:42,469 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 02:20:42,489 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 02:20:42,494 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 02:20:42,495 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 02:25:21,148 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-01 02:25:21,152 INFO core: _init_accounts_inner: reloading LLM config
2026-10-01 02:25:21,158 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 02:25:21,163 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-10-01 02:25:21,163 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-10-01 02:25:21,167 INFO core: Account 2: connecting to Telegram via 91.108.56.178...
2026-10-01 02:25:21,168 INFO telethon.network.mtprotosender: Connecting to 91.108.56.178:443/TcpAbridged...
2026-10-01 02:30:27,432 WARNING core: Account 2: connect timed out after 35s
2026-10-01 02:30:27,433 INFO telethon.network.mtprotosender: Disconnecting from 91.108.56.178:443/TcpAbridged...
2026-10-01 02:30:27,433 INFO telethon.network.mtprotosender: Disconnection from 91.108.56.178:443/TcpAbridged complete!
2026-10-01 02:30:27,434 INFO telethon.network.mtprotosender: Not disconnecting (already have no connection)
2026-10-01 02:30:27,435 INFO core: Account 2: connecting to Telegram via 91.108.56.181...
2026-10-01 02:30:29,706 INFO core: Event loop thread started, running loop forever
2026-10-01 02:30:30,013 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 02:30:30,025 INFO core: _init_accounts coroutine started
2026-10-01 02:30:30,025 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 02:30:30,050 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 02:35:04,650 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 02:35:04,650 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 02:35:04,661 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-01 02:35:04,668 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 02:40:10,409 INFO core: _init_accounts_inner: reloading LLM config
2026-10-01 02:40:10,410 WARNING core: LLM config load failed: cannot schedule new futures after shutdown
2026-10-01 02:40:44,124 INFO core: Event loop thread started, running loop forever
2026-10-01 02:40:44,426 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 02:40:44,431 INFO core: _init_accounts coroutine started
2026-10-01 02:40:44,433 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 02:40:44,466 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 02:45:09,811 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 02:50:08,518 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 02:50:08,518 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 02:50:08,519 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 02:55:09,149 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-01 02:55:09,153 INFO core: _init_accounts_inner: reloading LLM config
2026-10-01 02:55:09,171 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 03:00:08,490 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 03:05:28,117 INFO core: Event loop thread started, running loop forever
2026-10-01 03:05:28,420 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 03:05:28,427 INFO core: _init_accounts coroutine started
2026-10-01 03:05:28,430 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 03:05:28,442 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 03:10:27,518 INFO core: Event loop thread started, running loop forever
2026-10-01 03:10:27,819 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 03:10:27,823 INFO core: _init_accounts coroutine started
2026-10-01 03:10:27,823 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 03:10:27,840 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 03:10:35,523 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-10-01 03:15:34,500 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 149, in _init_accounts_inner
    await self._run_db(self.db.migrate_legacy_session)
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-10-01 03:15:50,345 INFO core: Event loop thread started, running loop forever
2026-10-01 03:15:50,647 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 03:15:50,653 INFO core: _init_accounts coroutine started
2026-10-01 03:15:50,654 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 03:15:50,656 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 03:20:49,920 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 03:25:45,866 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 03:25:45,871 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 03:25:45,879 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 03:30:30,174 INFO core: Event loop thread started, running loop forever
2026-10-01 03:30:30,475 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 03:30:30,481 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 03:35:10,236 INFO core: _init_accounts coroutine started
2026-10-01 03:35:10,239 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 03:35:10,249 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 03:40:16,386 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-10-01 03:40:33,590 INFO core: Event loop thread started, running loop forever
2026-10-01 03:40:33,891 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 03:40:33,895 INFO core: _init_accounts coroutine started
2026-10-01 03:40:33,896 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 03:40:33,901 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 03:45:10,863 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 03:50:14,628 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 03:50:14,631 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 03:50:14,638 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 03:55:20,381 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-01 03:55:20,381 WARNING core: ensure_pair_schema failed: cannot schedule new futures after shutdown
2026-10-01 03:55:35,514 INFO core: Event loop thread started, running loop forever
2026-10-01 03:55:35,815 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 03:55:35,821 INFO core: _init_accounts coroutine started
2026-10-01 03:55:35,821 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 03:55:35,825 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 04:00:41,625 INFO core: Event loop thread started, running loop forever
2026-10-01 04:00:41,926 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 04:00:41,932 INFO core: _init_accounts coroutine started
2026-10-01 04:00:41,932 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 04:00:41,940 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 04:05:17,183 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 04:10:23,420 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 149, in _init_accounts_inner
    await self._run_db(self.db.migrate_legacy_session)
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-10-01 04:10:51,558 INFO core: Event loop thread started, running loop forever
2026-10-01 04:10:51,859 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 04:10:51,863 INFO core: _init_accounts coroutine started
2026-10-01 04:10:51,865 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 04:10:51,870 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 04:15:52,655 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 04:20:13,444 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 04:20:13,456 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 04:20:13,468 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-01 04:20:13,473 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 04:25:42,199 INFO core: Event loop thread started, running loop forever
2026-10-01 04:25:42,499 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 04:25:42,503 INFO core: _init_accounts coroutine started
2026-10-01 04:25:42,505 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 04:25:42,524 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 04:30:10,876 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 04:30:10,877 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 04:30:10,883 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-01 04:30:10,886 INFO core: _init_accounts_inner: reloading LLM config
2026-10-01 04:30:10,893 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 04:35:19,114 INFO core: Event loop thread started, running loop forever
2026-10-01 04:35:19,416 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 04:35:19,423 INFO core: _init_accounts coroutine started
2026-10-01 04:35:19,423 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 04:35:19,447 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 04:35:19,448 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 04:35:19,452 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-01 04:35:19,454 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 04:35:19,456 INFO core: _init_accounts_inner: reloading LLM config
2026-10-01 04:40:13,846 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 04:45:35,893 INFO core: Event loop thread started, running loop forever
2026-10-01 04:45:36,195 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 04:45:36,199 INFO core: _init_accounts coroutine started
2026-10-01 04:45:36,201 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 04:45:36,305 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 04:50:25,157 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 04:50:25,158 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 04:50:25,281 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 04:55:06,777 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-01 04:55:06,783 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 04:55:06,785 INFO core: _init_accounts_inner: reloading LLM config
2026-10-01 04:55:06,806 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-10-01 04:55:06,807 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-10-01 04:55:06,813 INFO core: Account 2: connecting to Telegram via 91.108.56.178...
2026-10-01 04:55:06,814 INFO telethon.network.mtprotosender: Connecting to 91.108.56.178:443/TcpAbridged...
2026-10-01 05:00:12,458 WARNING telethon.network.mtprotosender: Attempt 1 at connecting failed: TimeoutError: 
2026-10-01 05:00:12,459 WARNING core: Account 2: connect timed out after 35s
2026-10-01 05:00:12,460 INFO telethon.network.mtprotosender: Disconnecting from 91.108.56.178:443/TcpAbridged...
2026-10-01 05:00:12,460 INFO telethon.network.mtprotosender: Disconnection from 91.108.56.178:443/TcpAbridged complete!
2026-10-01 05:00:12,461 INFO telethon.network.mtprotosender: Not disconnecting (already have no connection)
2026-10-01 05:00:41,750 INFO core: Event loop thread started, running loop forever
2026-10-01 05:00:42,052 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 05:00:42,058 INFO core: _init_accounts coroutine started
2026-10-01 05:00:42,058 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 05:00:42,062 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 05:05:40,581 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 05:10:32,372 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 05:10:32,373 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 05:10:32,375 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 05:15:42,477 INFO core: Event loop thread started, running loop forever
2026-10-01 05:15:42,778 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 05:15:42,782 INFO core: _init_accounts coroutine started
2026-10-01 05:15:42,784 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 05:15:42,788 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 05:20:41,791 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 05:25:18,306 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 05:30:14,931 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 05:30:14,931 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 05:30:14,934 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 05:35:15,499 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-01 05:35:15,502 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 05:40:29,636 INFO core: Event loop thread started, running loop forever
2026-10-01 05:40:29,937 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 05:40:29,946 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 05:45:48,934 INFO core: Event loop thread started, running loop forever
2026-10-01 05:45:49,235 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 05:45:49,239 INFO core: _init_accounts coroutine started
2026-10-01 05:45:49,240 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 05:45:49,243 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 05:50:12,069 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 126, in _init_accounts_inner
    accounts = await self._run_db(self.db.get_accounts)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 540, in get_accounts
    with self._conn() as conn:
         ~~~~~~~~~~^^
  File "/opt/alt/python313/lib64/python3.13/contextlib.py", line 141, in __enter__
    return next(self.gen)
  File "/home/wovewbge/quill.nx.kg/db.py", line 59, in _conn
    conn = _pool.connect()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 448, in connect
    return _ConnectionFairy._checkout(self)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 1272, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 712, in checkout
    rec = pool._do_get()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/impl.py", line 178, in _do_get
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/impl.py", line 176, in _do_get
    return self._create_connection()
           ~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection
    return _ConnectionRecord(self)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 674, in __init__
    self.__connect()
    ~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 900, in __connect
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 896, in __connect
    self.dbapi_connection = connection = pool._invoke_creator(self)
                                         ~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 361, in <lambda>
    return lambda rec: creator_fn()
                       ~~~~~~~~~~^^
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-10-01 05:50:12,096 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 05:55:09,344 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 06:00:30,449 INFO core: Event loop thread started, running loop forever
2026-10-01 06:00:30,750 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 06:00:30,755 INFO core: _init_accounts coroutine started
2026-10-01 06:00:30,755 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 06:00:30,765 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 06:05:16,734 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 06:10:24,908 INFO core: Event loop thread started, running loop forever
2026-10-01 06:10:25,216 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 06:10:25,222 INFO core: _init_accounts coroutine started
2026-10-01 06:10:25,222 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 06:10:25,232 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 06:15:16,500 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 06:15:16,500 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 06:15:16,501 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 06:20:10,111 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-01 06:20:10,120 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 06:20:10,121 INFO core: _init_accounts_inner: reloading LLM config
2026-10-01 06:25:38,761 INFO core: Event loop thread started, running loop forever
2026-10-01 06:25:39,063 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 06:25:39,066 INFO core: _init_accounts coroutine started
2026-10-01 06:25:39,069 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 06:25:39,074 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 06:30:06,476 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 06:30:06,478 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 06:30:06,482 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-01 06:30:06,482 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 06:30:06,483 INFO core: _init_accounts_inner: reloading LLM config
2026-10-01 06:35:06,486 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-10-01 06:35:06,503 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 06:35:06,519 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-10-01 06:35:06,526 INFO core: Account 2: connecting to Telegram via 91.108.56.178...
2026-10-01 06:35:06,527 INFO telethon.network.mtprotosender: Connecting to 91.108.56.178:443/TcpAbridged...
2026-10-01 06:40:14,781 INFO core: Event loop thread started, running loop forever
2026-10-01 06:40:15,082 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 06:40:15,086 INFO core: _init_accounts coroutine started
2026-10-01 06:40:15,087 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 06:40:15,095 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 06:45:21,390 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-10-01 06:45:41,269 INFO core: Event loop thread started, running loop forever
2026-10-01 06:45:41,570 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 06:45:41,726 INFO core: _init_accounts coroutine started
2026-10-01 06:45:41,726 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 06:45:41,730 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 06:50:38,666 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 06:55:41,219 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 06:55:41,219 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 06:55:41,227 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 07:00:48,384 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-01 07:00:48,386 WARNING core: ensure_pair_schema failed: cannot schedule new futures after shutdown
2026-10-01 07:00:48,387 INFO core: _init_accounts_inner: reloading LLM config
2026-10-01 07:00:48,387 WARNING core: LLM config load failed: cannot schedule new futures after shutdown
2026-10-01 07:00:48,387 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-10-01 07:00:48,387 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 180, in _init_accounts_inner
    await self._start_account_client(acct["id"])
  File "/home/wovewbge/quill.nx.kg/core.py", line 236, in _start_account_client
    session_str = await self._run_db(self.db.get_account_session, account_id)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-10-01 07:00:51,773 INFO core: Event loop thread started, running loop forever
2026-10-01 07:00:52,075 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 07:00:52,078 INFO core: _init_accounts coroutine started
2026-10-01 07:00:52,081 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 07:00:52,092 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 07:05:09,293 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 07:10:17,082 INFO core: Event loop thread started, running loop forever
2026-10-01 07:10:17,383 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 07:10:17,389 INFO core: _init_accounts coroutine started
2026-10-01 07:10:17,390 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 07:10:17,396 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 07:15:39,962 INFO core: Event loop thread started, running loop forever
2026-10-01 07:15:40,263 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 07:15:40,272 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 07:16:17,663 INFO core: _init_accounts coroutine started
2026-10-01 07:16:17,664 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 07:16:17,669 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 07:20:34,780 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 07:20:34,781 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 07:20:34,784 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 07:25:46,784 INFO core: Event loop thread started, running loop forever
2026-10-01 07:25:47,085 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 07:25:47,088 INFO core: _init_accounts coroutine started
2026-10-01 07:25:47,091 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 07:25:47,210 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 07:30:47,966 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 07:30:47,966 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 07:30:47,967 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 07:35:25,645 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 07:40:53,077 INFO core: Event loop thread started, running loop forever
2026-10-01 07:40:53,378 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 07:40:53,385 INFO core: _init_accounts coroutine started
2026-10-01 07:40:53,385 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 07:40:53,390 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 07:45:11,230 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 07:50:18,450 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 149, in _init_accounts_inner
    await self._run_db(self.db.migrate_legacy_session)
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-10-01 07:50:22,873 INFO core: Event loop thread started, running loop forever
2026-10-01 07:50:23,174 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 07:50:23,178 INFO core: _init_accounts coroutine started
2026-10-01 07:50:23,178 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 07:50:23,195 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 07:50:23,195 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 07:50:23,198 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-01 07:50:23,205 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 07:50:23,210 INFO core: _init_accounts_inner: reloading LLM config
2026-10-01 07:55:31,328 INFO core: Event loop thread started, running loop forever
2026-10-01 07:55:31,628 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 07:55:31,631 INFO core: _init_accounts coroutine started
2026-10-01 07:55:31,632 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 07:55:31,641 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 07:55:31,647 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 07:55:31,647 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 08:00:31,869 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-01 08:00:31,873 INFO core: _init_accounts_inner: reloading LLM config
2026-10-01 08:00:31,889 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 08:05:53,753 INFO core: Event loop thread started, running loop forever
2026-10-01 08:05:54,054 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 08:05:54,057 INFO core: _init_accounts coroutine started
2026-10-01 08:05:54,059 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 08:05:54,067 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 08:10:29,603 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 08:10:29,604 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 08:10:29,605 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-01 08:10:29,606 INFO core: _init_accounts_inner: reloading LLM config
2026-10-01 08:10:29,618 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 08:15:48,672 INFO core: Event loop thread started, running loop forever
2026-10-01 08:15:48,974 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 08:15:48,979 INFO core: _init_accounts coroutine started
2026-10-01 08:15:48,986 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 08:15:48,990 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 08:20:45,966 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 08:25:44,841 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 08:30:35,575 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 08:30:35,576 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 08:30:35,578 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-01 08:30:35,580 INFO core: _init_accounts_inner: reloading LLM config
2026-10-01 08:30:35,584 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 08:35:17,275 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 08:40:24,335 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-10-01 08:40:24,336 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-10-01 08:40:46,865 INFO core: Event loop thread started, running loop forever
2026-10-01 08:40:47,166 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 08:40:47,173 INFO core: _init_accounts coroutine started
2026-10-01 08:40:47,173 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 08:40:47,179 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 08:45:50,882 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 08:50:21,454 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 08:50:21,455 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 08:50:21,458 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-01 08:50:21,459 INFO core: _init_accounts_inner: reloading LLM config
2026-10-01 08:50:21,468 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-10-01 08:50:21,469 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-10-01 08:50:21,472 INFO core: Account 2: connecting to Telegram via 91.108.56.178...
2026-10-01 08:50:21,473 INFO telethon.network.mtprotosender: Connecting to 91.108.56.178:443/TcpAbridged...
2026-10-01 08:50:21,480 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 08:55:28,357 WARNING telethon.network.mtprotosender: Attempt 1 at connecting failed: TimeoutError: 
2026-10-01 08:55:28,359 WARNING core: Account 2: connect timed out after 35s
2026-10-01 08:55:28,360 INFO telethon.network.mtprotosender: Disconnecting from 91.108.56.178:443/TcpAbridged...
2026-10-01 08:55:28,360 INFO telethon.network.mtprotosender: Disconnection from 91.108.56.178:443/TcpAbridged complete!
2026-10-01 08:55:32,397 INFO core: Event loop thread started, running loop forever
2026-10-01 08:55:32,698 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 08:55:32,704 INFO core: _init_accounts coroutine started
2026-10-01 08:55:32,705 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 08:55:32,721 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 09:00:12,352 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 09:00:12,358 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 09:00:12,380 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-01 09:00:12,384 INFO core: _init_accounts_inner: reloading LLM config
2026-10-01 09:00:12,391 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 09:05:11,260 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 09:10:41,845 INFO core: Event loop thread started, running loop forever
2026-10-01 09:10:42,146 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 09:10:42,153 INFO core: _init_accounts coroutine started
2026-10-01 09:10:42,154 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 09:10:42,158 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 09:15:08,555 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 09:15:08,556 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 09:15:08,557 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-01 09:15:08,559 INFO core: _init_accounts_inner: reloading LLM config
2026-10-01 09:15:08,565 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 09:20:15,457 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-10-01 09:20:15,458 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-10-01 09:20:15,458 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 180, in _init_accounts_inner
    await self._start_account_client(acct["id"])
  File "/home/wovewbge/quill.nx.kg/core.py", line 236, in _start_account_client
    session_str = await self._run_db(self.db.get_account_session, account_id)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-10-01 09:20:23,763 INFO core: Event loop thread started, running loop forever
2026-10-01 09:20:24,064 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 09:20:24,069 INFO core: _init_accounts coroutine started
2026-10-01 09:20:24,070 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 09:20:24,078 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 09:25:10,342 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 09:30:27,224 INFO core: Event loop thread started, running loop forever
2026-10-01 09:30:27,525 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 09:30:27,530 INFO core: _init_accounts coroutine started
2026-10-01 09:30:27,533 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 09:30:27,536 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 09:35:34,396 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-10-01 09:35:35,315 INFO core: Event loop thread started, running loop forever
2026-10-01 09:35:35,617 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 09:35:35,620 INFO core: _init_accounts coroutine started
2026-10-01 09:35:35,623 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 09:35:35,631 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 09:40:04,177 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 09:40:04,178 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 09:40:04,180 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 09:45:49,994 INFO core: Event loop thread started, running loop forever
2026-10-01 09:45:50,295 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 09:45:50,301 INFO core: _init_accounts coroutine started
2026-10-01 09:45:50,302 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 09:45:50,307 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 09:50:17,760 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 09:50:17,762 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 09:50:17,762 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 09:55:30,747 INFO core: Event loop thread started, running loop forever
2026-10-01 09:55:31,048 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 09:55:31,053 INFO core: _init_accounts coroutine started
2026-10-01 09:55:31,054 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 09:55:31,060 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 10:00:44,784 INFO core: Event loop thread started, running loop forever
2026-10-01 10:00:45,085 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 10:00:45,088 INFO core: _init_accounts coroutine started
2026-10-01 10:00:45,090 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 10:00:45,099 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 10:00:45,104 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 10:00:45,106 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 10:05:05,165 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-01 10:05:05,168 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 10:10:04,949 INFO core: _init_accounts_inner: reloading LLM config
2026-10-01 10:10:04,955 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 10:15:21,200 INFO core: Event loop thread started, running loop forever
2026-10-01 10:15:21,502 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 10:15:21,505 INFO core: _init_accounts coroutine started
2026-10-01 10:15:21,505 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 10:15:21,520 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 10:20:15,435 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 10:20:15,435 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 10:20:15,438 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 10:25:24,070 INFO core: Event loop thread started, running loop forever
2026-10-01 10:25:24,371 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 10:25:24,375 INFO core: _init_accounts coroutine started
2026-10-01 10:25:24,377 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 10:25:24,389 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 10:30:19,768 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-10-01 10:30:19,788 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 10:35:05,304 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 10:40:25,804 INFO core: Event loop thread started, running loop forever
2026-10-01 10:40:26,105 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 10:40:26,116 INFO core: _init_accounts coroutine started
2026-10-01 10:40:26,116 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 10:40:26,125 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 10:40:26,127 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 10:40:26,127 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 10:45:07,253 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-01 10:45:07,255 INFO core: _init_accounts_inner: reloading LLM config
2026-10-01 10:45:07,266 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 10:50:14,372 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-10-01 10:50:14,374 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-10-01 10:50:24,104 INFO core: Event loop thread started, running loop forever
2026-10-01 10:50:24,405 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 10:50:24,409 INFO core: _init_accounts coroutine started
2026-10-01 10:50:24,409 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 10:50:24,425 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 10:55:41,558 INFO core: Event loop thread started, running loop forever
2026-10-01 10:55:41,859 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 10:55:41,862 INFO core: _init_accounts coroutine started
2026-10-01 10:55:41,864 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 10:55:41,870 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 11:00:14,974 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 11:00:14,974 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 11:00:14,975 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 11:05:18,741 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 11:10:06,595 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-01 11:10:06,600 INFO core: _init_accounts_inner: reloading LLM config
2026-10-01 11:10:06,632 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 11:15:51,068 INFO core: Event loop thread started, running loop forever
2026-10-01 11:15:51,369 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 11:15:51,372 INFO core: _init_accounts coroutine started
2026-10-01 11:15:51,374 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 11:15:51,380 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 11:20:46,781 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 11:20:46,781 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 11:20:46,784 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-01 11:20:46,785 INFO core: _init_accounts_inner: reloading LLM config
2026-10-01 11:20:46,794 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 11:20:46,796 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-10-01 11:20:46,796 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-10-01 11:20:46,800 INFO core: Account 2: connecting to Telegram via 91.108.56.178...
2026-10-01 11:20:46,801 INFO telethon.network.mtprotosender: Connecting to 91.108.56.178:443/TcpAbridged...
2026-10-01 11:25:19,331 WARNING telethon.network.mtprotosender: Attempt 1 at connecting failed: TimeoutError: 
2026-10-01 11:25:19,332 WARNING core: Account 2: connect timed out after 35s
2026-10-01 11:25:19,332 INFO telethon.network.mtprotosender: Disconnecting from 91.108.56.178:443/TcpAbridged...
2026-10-01 11:25:19,332 INFO telethon.network.mtprotosender: Disconnection from 91.108.56.178:443/TcpAbridged complete!
2026-10-01 11:25:19,333 INFO telethon.network.mtprotosender: Not disconnecting (already have no connection)
2026-10-01 11:25:19,334 INFO core: Account 2: connecting to Telegram via 91.108.56.181...
2026-10-01 11:25:19,336 INFO telethon.network.mtprotosender: Connecting to 91.108.56.181:443/TcpAbridged...
2026-10-01 11:25:19,340 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 11:30:25,701 WARNING telethon.network.mtprotosender: Attempt 1 at connecting failed: TimeoutError: 
2026-10-01 11:30:25,703 WARNING core: Account 2: connect timed out after 35s
2026-10-01 11:30:25,708 INFO core: Event loop thread started, running loop forever
2026-10-01 11:30:26,011 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 11:30:26,018 INFO core: _init_accounts coroutine started
2026-10-01 11:30:26,019 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 11:30:26,030 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 11:35:27,494 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 11:40:07,342 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 11:45:11,548 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 11:50:48,972 INFO core: Event loop thread started, running loop forever
2026-10-01 11:50:49,273 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 11:50:49,288 INFO core: _init_accounts coroutine started
2026-10-01 11:50:49,290 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 11:50:49,300 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 11:55:07,172 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 12:00:38,957 INFO core: Event loop thread started, running loop forever
2026-10-01 12:00:39,258 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 12:00:39,261 INFO core: _init_accounts coroutine started
2026-10-01 12:00:39,264 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 12:00:39,269 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 12:05:53,016 INFO core: Event loop thread started, running loop forever
2026-10-01 12:05:53,320 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 12:05:53,325 INFO core: _init_accounts coroutine started
2026-10-01 12:05:53,326 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 12:05:53,331 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 12:10:20,323 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 126, in _init_accounts_inner
    accounts = await self._run_db(self.db.get_accounts)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 540, in get_accounts
    with self._conn() as conn:
         ~~~~~~~~~~^^
  File "/opt/alt/python313/lib64/python3.13/contextlib.py", line 141, in __enter__
    return next(self.gen)
  File "/home/wovewbge/quill.nx.kg/db.py", line 59, in _conn
    conn = _pool.connect()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 448, in connect
    return _ConnectionFairy._checkout(self)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 1272, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 712, in checkout
    rec = pool._do_get()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/impl.py", line 178, in _do_get
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/impl.py", line 176, in _do_get
    return self._create_connection()
           ~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection
    return _ConnectionRecord(self)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 674, in __init__
    self.__connect()
    ~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 900, in __connect
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 896, in __connect
    self.dbapi_connection = connection = pool._invoke_creator(self)
                                         ~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 361, in <lambda>
    return lambda rec: creator_fn()
                       ~~~~~~~~~~^^
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-10-01 12:10:20,330 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 12:15:28,366 INFO core: Event loop thread started, running loop forever
2026-10-01 12:15:28,667 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 12:15:28,671 INFO core: _init_accounts coroutine started
2026-10-01 12:15:28,672 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 12:15:28,680 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 12:20:49,355 INFO core: Event loop thread started, running loop forever
2026-10-01 12:20:49,657 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 12:20:49,670 INFO core: _init_accounts coroutine started
2026-10-01 12:20:49,670 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 12:20:49,670 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 12:25:34,793 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 12:25:34,795 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 12:25:34,802 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 12:30:29,769 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-01 12:30:29,784 INFO core: _init_accounts_inner: reloading LLM config
2026-10-01 12:30:29,818 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 12:35:04,939 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 12:40:10,403 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-10-01 12:40:10,404 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-10-01 12:40:40,898 INFO core: Event loop thread started, running loop forever
2026-10-01 12:40:41,199 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 12:40:41,208 INFO core: _init_accounts coroutine started
2026-10-01 12:40:41,209 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 12:40:41,244 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 12:45:06,803 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 12:50:12,409 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 12:50:12,410 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 12:50:12,410 WARNING core: ensure_llm_schema failed: cannot schedule new futures after shutdown
2026-10-01 12:50:12,411 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-01 12:50:12,411 WARNING core: ensure_pair_schema failed: cannot schedule new futures after shutdown
2026-10-01 12:50:12,411 INFO core: _init_accounts_inner: reloading LLM config
2026-10-01 12:50:12,411 WARNING core: LLM config load failed: cannot schedule new futures after shutdown
2026-10-01 12:50:12,411 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-10-01 12:50:12,412 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 180, in _init_accounts_inner
    await self._start_account_client(acct["id"])
  File "/home/wovewbge/quill.nx.kg/core.py", line 236, in _start_account_client
    session_str = await self._run_db(self.db.get_account_session, account_id)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-10-01 12:50:42,464 INFO core: Event loop thread started, running loop forever
2026-10-01 12:50:42,765 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 12:50:42,771 INFO core: _init_accounts coroutine started
2026-10-01 12:50:42,771 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 12:50:42,783 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 12:55:31,291 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 12:55:31,292 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 12:55:31,294 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 13:00:16,746 INFO core: Event loop thread started, running loop forever
2026-10-01 13:00:17,047 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 13:00:17,053 INFO core: _init_accounts coroutine started
2026-10-01 13:00:17,054 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 13:00:17,058 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 13:05:39,759 INFO core: Event loop thread started, running loop forever
2026-10-01 13:05:40,059 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 13:05:40,064 INFO core: _init_accounts coroutine started
2026-10-01 13:05:40,065 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 13:05:40,073 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 13:10:18,941 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 13:10:18,941 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 13:10:18,955 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-01 13:10:18,957 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 13:10:18,958 INFO core: _init_accounts_inner: reloading LLM config
2026-10-01 13:15:15,942 INFO core: Event loop thread started, running loop forever
2026-10-01 13:15:16,243 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 13:15:16,254 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 13:15:26,003 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-10-01 13:15:26,003 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-10-01 13:20:22,441 INFO core: _init_accounts coroutine started
2026-10-01 13:20:22,442 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 13:20:25,084 INFO core: Event loop thread started, running loop forever
2026-10-01 13:20:25,385 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 13:20:25,390 INFO core: _init_accounts coroutine started
2026-10-01 13:20:25,390 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 13:20:25,397 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 13:25:43,399 INFO core: Event loop thread started, running loop forever
2026-10-01 13:25:43,700 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 13:25:43,705 INFO core: _init_accounts coroutine started
2026-10-01 13:25:43,705 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 13:25:43,726 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 13:25:43,726 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 13:25:43,727 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-01 13:25:43,728 INFO core: _init_accounts_inner: reloading LLM config
2026-10-01 13:25:43,737 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-10-01 13:25:43,737 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-10-01 13:25:43,741 INFO core: Account 2: connecting to Telegram via 91.108.56.178...
2026-10-01 13:25:43,742 INFO telethon.network.mtprotosender: Connecting to 91.108.56.178:443/TcpAbridged...
2026-10-01 13:25:43,750 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 13:30:08,364 WARNING telethon.network.mtprotosender: Attempt 1 at connecting failed: TimeoutError: 
2026-10-01 13:30:08,365 WARNING core: Account 2: connect timed out after 35s
2026-10-01 13:30:08,365 INFO telethon.network.mtprotosender: Disconnecting from 91.108.56.178:443/TcpAbridged...
2026-10-01 13:30:08,365 INFO telethon.network.mtprotosender: Disconnection from 91.108.56.178:443/TcpAbridged complete!
2026-10-01 13:30:08,366 INFO telethon.network.mtprotosender: Not disconnecting (already have no connection)
2026-10-01 13:30:08,367 INFO core: Account 2: connecting to Telegram via 91.108.56.181...
2026-10-01 13:30:08,367 INFO telethon.network.mtprotosender: Connecting to 91.108.56.181:443/TcpAbridged...
2026-10-01 13:30:18,722 INFO core: Event loop thread started, running loop forever
2026-10-01 13:30:19,023 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 13:30:19,029 INFO core: _init_accounts coroutine started
2026-10-01 13:30:19,030 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 13:30:19,036 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 13:35:54,603 INFO core: Event loop thread started, running loop forever
2026-10-01 13:35:54,904 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 13:35:54,907 INFO core: _init_accounts coroutine started
2026-10-01 13:35:54,908 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 13:35:54,923 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 13:40:31,220 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 13:40:31,226 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 13:40:31,226 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 13:45:15,785 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-01 13:45:15,799 INFO core: _init_accounts_inner: reloading LLM config
2026-10-01 13:45:15,801 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 13:50:25,841 INFO core: Event loop thread started, running loop forever
2026-10-01 13:50:26,141 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 13:50:26,145 INFO core: _init_accounts coroutine started
2026-10-01 13:50:26,146 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 13:50:26,151 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 13:55:18,998 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 14:00:24,328 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 14:00:24,328 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 14:00:24,333 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-01 14:00:24,344 INFO core: _init_accounts_inner: reloading LLM config
2026-10-01 14:00:24,364 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 14:05:44,181 INFO core: Event loop thread started, running loop forever
2026-10-01 14:05:44,482 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 14:05:44,487 INFO core: _init_accounts coroutine started
2026-10-01 14:05:44,488 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 14:05:44,493 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 14:10:30,608 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 14:10:30,608 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 14:10:30,620 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 14:15:36,437 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-01 14:15:36,438 WARNING core: ensure_pair_schema failed: cannot schedule new futures after shutdown
2026-10-01 14:15:36,439 INFO core: _init_accounts_inner: reloading LLM config
2026-10-01 14:15:36,440 WARNING core: LLM config load failed: cannot schedule new futures after shutdown
2026-10-01 14:15:36,440 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-10-01 14:15:36,440 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 180, in _init_accounts_inner
    await self._start_account_client(acct["id"])
  File "/home/wovewbge/quill.nx.kg/core.py", line 236, in _start_account_client
    session_str = await self._run_db(self.db.get_account_session, account_id)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-10-01 14:15:39,948 INFO core: Event loop thread started, running loop forever
2026-10-01 14:15:40,250 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 14:15:40,254 INFO core: _init_accounts coroutine started
2026-10-01 14:15:40,255 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 14:15:40,279 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 14:15:40,286 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 14:15:40,293 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 14:20:49,883 INFO core: Event loop thread started, running loop forever
2026-10-01 14:20:50,184 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 14:20:50,188 INFO core: _init_accounts coroutine started
2026-10-01 14:20:50,189 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 14:20:50,200 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 14:25:20,347 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 14:25:20,349 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 14:25:20,349 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 14:30:47,873 INFO core: Event loop thread started, running loop forever
2026-10-01 14:30:48,177 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 14:30:48,180 INFO core: _init_accounts coroutine started
2026-10-01 14:30:48,182 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 14:30:48,189 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 14:35:28,548 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 14:35:28,548 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 14:35:28,549 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 14:40:13,446 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-01 14:40:13,451 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 14:40:13,452 INFO core: _init_accounts_inner: reloading LLM config
2026-10-01 14:45:27,478 INFO core: Event loop thread started, running loop forever
2026-10-01 14:45:27,779 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 14:45:27,785 INFO core: _init_accounts coroutine started
2026-10-01 14:45:27,785 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 14:45:27,788 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 14:50:15,396 INFO core: Event loop thread started, running loop forever
2026-10-01 14:50:15,697 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 14:50:15,700 INFO core: _init_accounts coroutine started
2026-10-01 14:50:15,702 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 14:50:15,707 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 14:55:22,773 INFO core: Event loop thread started, running loop forever
2026-10-01 14:55:23,074 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 14:55:23,079 INFO core: _init_accounts coroutine started
2026-10-01 14:55:23,080 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 14:55:23,087 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 15:00:42,086 INFO core: Event loop thread started, running loop forever
2026-10-01 15:00:42,388 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 15:00:42,393 INFO core: _init_accounts coroutine started
2026-10-01 15:00:42,394 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 15:00:42,401 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 15:05:43,495 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 15:10:38,452 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 15:10:38,453 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 15:10:38,458 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 15:15:11,464 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-01 15:15:11,470 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 15:15:11,470 INFO core: _init_accounts_inner: reloading LLM config
2026-10-01 15:20:08,085 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 15:25:46,142 INFO core: Event loop thread started, running loop forever
2026-10-01 15:25:46,443 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 15:25:46,446 INFO core: _init_accounts coroutine started
2026-10-01 15:25:46,447 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 15:25:46,456 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 15:30:38,929 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 15:30:38,930 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 15:30:38,940 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-01 15:30:38,942 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 15:30:38,943 INFO core: _init_accounts_inner: reloading LLM config
2026-10-01 15:35:13,282 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 15:40:12,906 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 15:40:12,907 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-10-01 15:45:04,335 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-10-01 15:45:12,525 INFO core: Event loop thread started, running loop forever
2026-10-01 15:45:12,826 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 15:45:12,830 INFO core: _init_accounts coroutine started
2026-10-01 15:45:12,831 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 15:45:12,834 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 15:50:11,145 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 126, in _init_accounts_inner
    accounts = await self._run_db(self.db.get_accounts)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 540, in get_accounts
    with self._conn() as conn:
         ~~~~~~~~~~^^
  File "/opt/alt/python313/lib64/python3.13/contextlib.py", line 141, in __enter__
    return next(self.gen)
  File "/home/wovewbge/quill.nx.kg/db.py", line 59, in _conn
    conn = _pool.connect()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 448, in connect
    return _ConnectionFairy._checkout(self)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 1272, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 712, in checkout
    rec = pool._do_get()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/impl.py", line 178, in _do_get
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/impl.py", line 176, in _do_get
    return self._create_connection()
           ~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection
    return _ConnectionRecord(self)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 674, in __init__
    self.__connect()
    ~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 900, in __connect
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 896, in __connect
    self.dbapi_connection = connection = pool._invoke_creator(self)
                                         ~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 361, in <lambda>
    return lambda rec: creator_fn()
                       ~~~~~~~~~~^^
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-10-01 15:50:11,151 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 15:55:15,133 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 16:00:15,454 INFO app: Retrying account initialization (clients=0 but authorized accounts in DB)
2026-10-01 16:00:15,455 INFO core: _init_accounts coroutine started
2026-10-01 16:00:15,455 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 16:00:15,461 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 16:05:42,534 INFO core: Event loop thread started, running loop forever
2026-10-01 16:05:42,836 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 16:05:42,843 INFO core: _init_accounts coroutine started
2026-10-01 16:05:42,844 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 16:05:42,850 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 16:10:23,965 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 16:15:51,887 INFO core: Event loop thread started, running loop forever
2026-10-01 16:15:52,188 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 16:15:52,197 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 16:20:38,154 INFO core: _init_accounts coroutine started
2026-10-01 16:20:38,155 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 16:20:38,163 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 16:25:03,674 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 16:30:09,404 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 149, in _init_accounts_inner
    await self._run_db(self.db.migrate_legacy_session)
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 687, in migrate_legacy_session
    with self._conn() as conn:
         ~~~~~~~~~~^^
  File "/opt/alt/python313/lib64/python3.13/contextlib.py", line 141, in __enter__
    return next(self.gen)
  File "/home/wovewbge/quill.nx.kg/db.py", line 59, in _conn
    conn = _pool.connect()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 448, in connect
    return _ConnectionFairy._checkout(self)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 1272, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 717, in checkout
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 715, in checkout
    dbapi_connection = rec.get_connection()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 866, in get_connection
    self.__connect()
    ~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 900, in __connect
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 896, in __connect
    self.dbapi_connection = connection = pool._invoke_creator(self)
                                         ~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 361, in <lambda>
    return lambda rec: creator_fn()
                       ~~~~~~~~~~^^
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-10-01 16:30:35,443 INFO core: Event loop thread started, running loop forever
2026-10-01 16:30:35,744 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 16:30:35,747 INFO core: _init_accounts coroutine started
2026-10-01 16:30:35,749 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 16:30:35,756 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 16:35:21,005 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 16:35:21,006 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 16:35:21,008 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-01 16:35:21,009 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 16:40:16,684 INFO core: _init_accounts_inner: reloading LLM config
2026-10-01 16:40:16,688 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 16:45:28,857 INFO core: Event loop thread started, running loop forever
2026-10-01 16:45:29,159 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 16:45:29,163 INFO core: _init_accounts coroutine started
2026-10-01 16:45:29,165 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 16:45:29,174 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 16:50:28,532 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 16:50:28,532 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 16:50:28,534 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-01 16:50:28,534 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 16:50:28,535 INFO core: _init_accounts_inner: reloading LLM config
2026-10-01 16:55:29,363 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 17:00:35,435 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-10-01 17:00:52,484 INFO core: Event loop thread started, running loop forever
2026-10-01 17:00:52,794 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 17:00:52,797 INFO core: _init_accounts coroutine started
2026-10-01 17:00:52,799 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 17:00:52,805 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 17:05:31,635 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 17:05:31,636 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 17:05:31,638 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-01 17:05:31,638 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 17:10:09,183 INFO core: _init_accounts_inner: reloading LLM config
2026-10-01 17:10:09,190 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 17:15:17,363 INFO core: Event loop thread started, running loop forever
2026-10-01 17:15:17,665 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 17:15:17,672 INFO core: _init_accounts coroutine started
2026-10-01 17:15:17,673 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 17:15:17,688 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 17:15:17,688 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 17:15:17,690 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 17:15:17,693 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-01 17:20:24,419 INFO core: _init_accounts_inner: reloading LLM config
2026-10-01 17:20:47,062 INFO core: Event loop thread started, running loop forever
2026-10-01 17:20:47,363 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 17:20:47,367 INFO core: _init_accounts coroutine started
2026-10-01 17:20:47,368 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 17:20:47,374 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 17:25:17,422 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 17:30:21,396 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 17:30:21,397 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 17:30:21,398 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-01 17:30:21,399 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 17:35:07,953 INFO core: _init_accounts_inner: reloading LLM config
2026-10-01 17:35:07,967 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 17:40:30,561 INFO core: Event loop thread started, running loop forever
2026-10-01 17:40:30,862 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 17:40:30,866 INFO core: _init_accounts coroutine started
2026-10-01 17:40:30,867 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 17:40:30,873 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 17:45:20,776 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 17:50:19,012 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 149, in _init_accounts_inner
    await self._run_db(self.db.migrate_legacy_session)
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 687, in migrate_legacy_session
    with self._conn() as conn:
         ~~~~~~~~~~^^
  File "/opt/alt/python313/lib64/python3.13/contextlib.py", line 141, in __enter__
    return next(self.gen)
  File "/home/wovewbge/quill.nx.kg/db.py", line 59, in _conn
    conn = _pool.connect()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 448, in connect
    return _ConnectionFairy._checkout(self)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 1272, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 717, in checkout
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 715, in checkout
    dbapi_connection = rec.get_connection()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 866, in get_connection
    self.__connect()
    ~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 900, in __connect
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 896, in __connect
    self.dbapi_connection = connection = pool._invoke_creator(self)
                                         ~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 361, in <lambda>
    return lambda rec: creator_fn()
                       ~~~~~~~~~~^^
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-10-01 17:50:19,038 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 17:55:21,887 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 18:00:53,176 INFO core: Event loop thread started, running loop forever
2026-10-01 18:00:53,478 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 18:00:53,485 INFO core: _init_accounts coroutine started
2026-10-01 18:00:53,485 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 18:00:53,489 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 18:05:46,550 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 18:10:25,813 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 18:15:10,275 INFO core: Event loop thread started, running loop forever
2026-10-01 18:15:10,578 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 18:15:10,588 INFO core: _init_accounts coroutine started
2026-10-01 18:15:10,588 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 18:15:10,592 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 18:20:19,161 INFO core: Event loop thread started, running loop forever
2026-10-01 18:20:19,462 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 18:20:19,468 INFO core: _init_accounts coroutine started
2026-10-01 18:20:19,468 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 18:20:19,474 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 18:25:12,151 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 18:25:12,151 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 18:25:12,155 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 18:30:33,673 INFO core: Event loop thread started, running loop forever
2026-10-01 18:30:33,974 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 18:30:33,979 INFO core: _init_accounts coroutine started
2026-10-01 18:30:33,979 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 18:30:33,983 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 18:35:12,301 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 18:35:12,302 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 18:35:12,302 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 18:35:12,304 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-01 18:40:35,689 INFO core: Event loop thread started, running loop forever
2026-10-01 18:40:35,990 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 18:40:35,992 INFO core: _init_accounts coroutine started
2026-10-01 18:40:35,994 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 18:40:36,000 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 18:45:10,050 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 18:50:06,154 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 149, in _init_accounts_inner
    await self._run_db(self.db.migrate_legacy_session)
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 687, in migrate_legacy_session
    with self._conn() as conn:
         ~~~~~~~~~~^^
  File "/opt/alt/python313/lib64/python3.13/contextlib.py", line 141, in __enter__
    return next(self.gen)
  File "/home/wovewbge/quill.nx.kg/db.py", line 59, in _conn
    conn = _pool.connect()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 448, in connect
    return _ConnectionFairy._checkout(self)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 1272, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 717, in checkout
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 715, in checkout
    dbapi_connection = rec.get_connection()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 866, in get_connection
    self.__connect()
    ~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 900, in __connect
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 896, in __connect
    self.dbapi_connection = connection = pool._invoke_creator(self)
                                         ~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 361, in <lambda>
    return lambda rec: creator_fn()
                       ~~~~~~~~~~^^
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-10-01 18:50:06,162 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 18:55:23,965 INFO core: Event loop thread started, running loop forever
2026-10-01 18:55:24,266 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 18:55:24,270 INFO core: _init_accounts coroutine started
2026-10-01 18:55:24,273 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 18:55:24,277 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 19:00:53,607 INFO core: Event loop thread started, running loop forever
2026-10-01 19:00:53,915 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 19:00:53,922 INFO core: _init_accounts coroutine started
2026-10-01 19:00:53,922 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 19:00:53,930 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 19:05:34,422 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 19:10:05,395 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 19:10:05,395 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 19:10:05,398 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 19:10:05,398 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-01 19:15:45,653 INFO core: Event loop thread started, running loop forever
2026-10-01 19:15:45,954 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 19:15:45,957 INFO core: _init_accounts coroutine started
2026-10-01 19:15:45,958 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 19:15:45,963 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 19:20:25,197 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 19:25:40,082 INFO core: Event loop thread started, running loop forever
2026-10-01 19:25:40,383 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 19:25:40,389 INFO core: _init_accounts coroutine started
2026-10-01 19:25:40,389 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 19:25:40,396 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 19:30:42,476 INFO core: Event loop thread started, running loop forever
2026-10-01 19:30:42,786 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 19:30:42,789 INFO core: _init_accounts coroutine started
2026-10-01 19:30:42,791 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 19:30:42,797 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 19:35:39,063 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-10-01 19:35:39,073 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 19:40:32,044 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 19:45:12,684 INFO app: Retrying account initialization (clients=0 but authorized accounts in DB)
2026-10-01 19:45:12,685 INFO core: _init_accounts coroutine started
2026-10-01 19:45:12,685 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 19:45:12,690 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 19:50:18,353 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 19:50:50,562 INFO core: Event loop thread started, running loop forever
2026-10-01 19:50:50,862 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 19:50:50,865 INFO core: _init_accounts coroutine started
2026-10-01 19:50:50,867 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 19:50:50,873 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 19:55:19,440 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 19:55:19,440 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 19:55:19,442 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 19:55:19,442 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-01 20:00:29,297 INFO core: Event loop thread started, running loop forever
2026-10-01 20:00:29,598 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 20:00:29,600 INFO core: _init_accounts coroutine started
2026-10-01 20:00:29,603 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 20:00:29,612 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 20:05:05,293 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 20:10:11,358 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-10-01 20:10:18,832 INFO core: Event loop thread started, running loop forever
2026-10-01 20:10:19,133 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 20:10:19,137 INFO core: _init_accounts coroutine started
2026-10-01 20:10:19,138 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 20:10:19,151 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 20:15:43,247 INFO core: Event loop thread started, running loop forever
2026-10-01 20:15:43,548 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 20:15:43,552 INFO core: _init_accounts coroutine started
2026-10-01 20:15:43,554 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 20:15:43,563 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 20:20:32,228 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 20:20:32,228 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 20:20:32,230 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-01 20:20:32,230 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 20:25:07,194 INFO core: _init_accounts_inner: reloading LLM config
2026-10-01 20:25:07,197 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 20:30:15,848 INFO core: Event loop thread started, running loop forever
2026-10-01 20:30:16,150 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 20:30:16,157 INFO core: _init_accounts coroutine started
2026-10-01 20:30:16,158 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 20:30:16,160 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 20:35:23,584 INFO core: Event loop thread started, running loop forever
2026-10-01 20:35:23,885 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 20:35:23,888 INFO core: _init_accounts coroutine started
2026-10-01 20:35:23,889 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 20:35:23,895 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 20:40:29,370 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 149, in _init_accounts_inner
    await self._run_db(self.db.migrate_legacy_session)
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-10-01 20:40:36,577 INFO core: Event loop thread started, running loop forever
2026-10-01 20:40:36,877 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 20:40:36,883 INFO core: _init_accounts coroutine started
2026-10-01 20:40:36,883 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 20:40:36,887 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 20:45:43,395 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-10-01 20:45:45,739 INFO core: Event loop thread started, running loop forever
2026-10-01 20:45:46,040 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 20:45:46,115 INFO core: _init_accounts coroutine started
2026-10-01 20:45:46,115 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 20:45:46,135 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 20:50:23,322 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 126, in _init_accounts_inner
    accounts = await self._run_db(self.db.get_accounts)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 540, in get_accounts
    with self._conn() as conn:
         ~~~~~~~~~~^^
  File "/opt/alt/python313/lib64/python3.13/contextlib.py", line 141, in __enter__
    return next(self.gen)
  File "/home/wovewbge/quill.nx.kg/db.py", line 59, in _conn
    conn = _pool.connect()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 448, in connect
    return _ConnectionFairy._checkout(self)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 1272, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 712, in checkout
    rec = pool._do_get()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/impl.py", line 178, in _do_get
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/impl.py", line 176, in _do_get
    return self._create_connection()
           ~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection
    return _ConnectionRecord(self)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 674, in __init__
    self.__connect()
    ~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 900, in __connect
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 896, in __connect
    self.dbapi_connection = connection = pool._invoke_creator(self)
                                         ~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 361, in <lambda>
    return lambda rec: creator_fn()
                       ~~~~~~~~~~^^
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-10-01 20:50:23,333 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 20:55:30,173 INFO core: Event loop thread started, running loop forever
2026-10-01 20:55:30,473 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 20:55:30,477 INFO core: _init_accounts coroutine started
2026-10-01 20:55:30,480 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 20:55:30,485 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 21:00:25,126 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-10-01 21:00:25,143 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 21:05:17,754 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 21:10:16,255 INFO app: Retrying account initialization (clients=0 but authorized accounts in DB)
2026-10-01 21:10:16,256 INFO core: _init_accounts coroutine started
2026-10-01 21:10:16,256 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 21:10:16,261 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 21:10:16,261 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 21:10:16,263 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-01 21:10:16,263 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 21:15:23,387 INFO core: _init_accounts_inner: reloading LLM config
2026-10-01 21:15:23,388 WARNING core: LLM config load failed: cannot schedule new futures after shutdown
2026-10-01 21:15:23,388 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-10-01 21:15:26,766 INFO core: Event loop thread started, running loop forever
2026-10-01 21:15:27,070 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 21:15:27,074 INFO core: _init_accounts coroutine started
2026-10-01 21:15:27,075 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 21:15:27,082 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 21:20:51,773 INFO core: Event loop thread started, running loop forever
2026-10-01 21:20:52,074 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 21:20:52,078 INFO core: _init_accounts coroutine started
2026-10-01 21:20:52,079 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 21:20:52,086 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 21:25:17,476 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 21:30:40,617 INFO core: Event loop thread started, running loop forever
2026-10-01 21:30:40,918 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 21:30:40,924 INFO core: _init_accounts coroutine started
2026-10-01 21:30:40,925 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 21:30:40,937 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 21:30:40,938 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 21:30:40,939 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-01 21:30:40,940 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 21:35:35,682 INFO core: _init_accounts_inner: reloading LLM config
2026-10-01 21:35:35,692 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 21:40:23,460 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 21:45:34,409 INFO core: Event loop thread started, running loop forever
2026-10-01 21:45:34,710 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 21:45:34,715 INFO core: _init_accounts coroutine started
2026-10-01 21:45:34,716 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 21:45:34,720 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 21:50:46,494 INFO core: Event loop thread started, running loop forever
2026-10-01 21:50:46,795 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 21:50:46,920 INFO core: _init_accounts coroutine started
2026-10-01 21:50:46,920 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 21:50:46,927 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 21:55:50,883 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 22:00:15,869 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 22:05:46,914 INFO core: Event loop thread started, running loop forever
2026-10-01 22:05:47,215 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 22:05:47,217 INFO core: _init_accounts coroutine started
2026-10-01 22:05:47,219 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 22:05:47,228 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 22:10:31,668 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-10-01 22:10:31,681 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 22:15:50,131 INFO core: Event loop thread started, running loop forever
2026-10-01 22:15:50,433 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 22:15:50,437 INFO core: _init_accounts coroutine started
2026-10-01 22:15:50,438 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 22:15:50,461 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 22:20:52,467 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 22:25:12,661 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 22:25:12,661 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 22:25:12,663 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 22:30:18,374 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-01 22:30:18,375 WARNING core: ensure_pair_schema failed: cannot schedule new futures after shutdown
2026-10-01 22:30:18,376 INFO core: _init_accounts_inner: reloading LLM config
2026-10-01 22:30:18,376 WARNING core: LLM config load failed: cannot schedule new futures after shutdown
2026-10-01 22:30:18,376 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-10-01 22:30:18,376 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 180, in _init_accounts_inner
    await self._start_account_client(acct["id"])
  File "/home/wovewbge/quill.nx.kg/core.py", line 236, in _start_account_client
    session_str = await self._run_db(self.db.get_account_session, account_id)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-10-01 22:30:28,070 INFO core: Event loop thread started, running loop forever
2026-10-01 22:30:28,372 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 22:30:28,376 INFO core: _init_accounts coroutine started
2026-10-01 22:30:28,378 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 22:30:28,384 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 22:35:27,173 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 22:40:11,167 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 22:40:11,169 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 22:45:18,405 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 22:45:18,406 WARNING core: ensure_llm_schema failed: cannot schedule new futures after shutdown
2026-10-01 22:45:18,407 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-01 22:45:18,407 WARNING core: ensure_pair_schema failed: cannot schedule new futures after shutdown
2026-10-01 22:45:34,759 INFO core: Event loop thread started, running loop forever
2026-10-01 22:45:35,061 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 22:45:35,068 INFO core: _init_accounts coroutine started
2026-10-01 22:45:35,069 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 22:45:35,076 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 22:50:37,229 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 22:55:17,153 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 22:55:17,153 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 22:55:17,156 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 23:00:24,401 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-01 23:00:24,401 WARNING core: ensure_pair_schema failed: cannot schedule new futures after shutdown
2026-10-01 23:00:24,402 INFO core: _init_accounts_inner: reloading LLM config
2026-10-01 23:00:27,193 INFO core: Event loop thread started, running loop forever
2026-10-01 23:00:27,494 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 23:00:27,502 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 23:05:34,365 INFO core: _init_accounts coroutine started
2026-10-01 23:05:34,366 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 23:05:43,194 INFO core: Event loop thread started, running loop forever
2026-10-01 23:05:43,495 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 23:05:43,499 INFO core: _init_accounts coroutine started
2026-10-01 23:05:43,501 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 23:05:43,509 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 23:10:26,937 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 23:15:18,586 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 23:15:18,586 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 23:15:18,608 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 23:15:18,608 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-01 23:20:17,212 INFO core: _init_accounts_inner: reloading LLM config
2026-10-01 23:20:17,216 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 23:25:24,373 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-10-01 23:25:24,373 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-10-01 23:25:44,121 INFO core: Event loop thread started, running loop forever
2026-10-01 23:25:44,424 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 23:25:44,428 INFO core: _init_accounts coroutine started
2026-10-01 23:25:44,429 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 23:25:44,436 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 23:25:44,436 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 23:25:44,437 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-01 23:25:44,438 INFO core: _init_accounts_inner: reloading LLM config
2026-10-01 23:25:44,439 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 23:30:14,527 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 23:35:25,775 INFO core: Event loop thread started, running loop forever
2026-10-01 23:35:26,077 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 23:35:26,081 INFO core: _init_accounts coroutine started
2026-10-01 23:35:26,082 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 23:35:26,089 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 23:40:13,780 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 23:40:13,780 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 23:40:13,781 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-01 23:40:13,782 INFO core: _init_accounts_inner: reloading LLM config
2026-10-01 23:40:13,785 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 23:45:32,933 INFO core: Event loop thread started, running loop forever
2026-10-01 23:45:33,234 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 23:45:33,237 INFO core: _init_accounts coroutine started
2026-10-01 23:45:33,238 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 23:45:33,247 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-01 23:45:33,247 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-01 23:45:33,249 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 23:45:33,249 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-01 23:50:39,376 INFO core: _init_accounts_inner: reloading LLM config
2026-10-01 23:50:39,376 WARNING core: LLM config load failed: cannot schedule new futures after shutdown
2026-10-01 23:50:39,376 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-10-01 23:50:40,099 INFO core: Event loop thread started, running loop forever
2026-10-01 23:50:40,404 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-01 23:50:40,407 INFO core: _init_accounts coroutine started
2026-10-01 23:50:40,408 INFO core: _init_accounts_inner: starting DB migrations
2026-10-01 23:50:40,425 INFO core: status() clients=0 connected=False forwarding=False
2026-10-01 23:55:35,988 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 126, in _init_accounts_inner
    accounts = await self._run_db(self.db.get_accounts)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 540, in get_accounts
    with self._conn() as conn:
         ~~~~~~~~~~^^
  File "/opt/alt/python313/lib64/python3.13/contextlib.py", line 141, in __enter__
    return next(self.gen)
  File "/home/wovewbge/quill.nx.kg/db.py", line 59, in _conn
    conn = _pool.connect()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 448, in connect
    return _ConnectionFairy._checkout(self)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 1272, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 712, in checkout
    rec = pool._do_get()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/impl.py", line 178, in _do_get
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/impl.py", line 176, in _do_get
    return self._create_connection()
           ~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection
    return _ConnectionRecord(self)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 674, in __init__
    self.__connect()
    ~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 900, in __connect
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 896, in __connect
    self.dbapi_connection = connection = pool._invoke_creator(self)
                                         ~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 361, in <lambda>
    return lambda rec: creator_fn()
                       ~~~~~~~~~~^^
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-10-01 23:55:35,996 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 00:00:16,827 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 00:05:19,097 INFO app: Retrying account initialization (clients=0 but authorized accounts in DB)
2026-10-02 00:05:19,098 INFO core: _init_accounts coroutine started
2026-10-02 00:05:19,098 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 00:05:19,103 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-02 00:05:19,103 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-02 00:05:19,105 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-02 00:05:19,105 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 00:10:09,379 INFO core: _init_accounts_inner: reloading LLM config
2026-10-02 00:10:09,384 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 00:15:41,906 INFO core: Event loop thread started, running loop forever
2026-10-02 00:15:42,207 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 00:15:42,212 INFO core: _init_accounts coroutine started
2026-10-02 00:15:42,213 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 00:15:42,223 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 00:20:48,393 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 149, in _init_accounts_inner
    await self._run_db(self.db.migrate_legacy_session)
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-10-02 00:20:48,506 INFO core: Event loop thread started, running loop forever
2026-10-02 00:20:48,807 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 00:20:48,828 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 00:25:33,568 INFO core: _init_accounts coroutine started
2026-10-02 00:25:33,570 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 00:25:33,576 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 00:30:34,674 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-02 00:30:34,674 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-02 00:30:34,676 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 00:35:30,949 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-02 00:35:30,952 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 00:40:52,498 INFO core: Event loop thread started, running loop forever
2026-10-02 00:40:52,799 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 00:40:52,803 INFO core: _init_accounts coroutine started
2026-10-02 00:40:52,805 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 00:40:52,825 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 00:45:50,262 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 00:50:18,273 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-02 00:50:18,273 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-02 00:50:18,282 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-02 00:50:18,283 INFO core: _init_accounts_inner: reloading LLM config
2026-10-02 00:50:18,286 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 00:55:46,611 INFO core: Event loop thread started, running loop forever
2026-10-02 00:55:46,914 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 00:55:46,917 INFO core: _init_accounts coroutine started
2026-10-02 00:55:46,928 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 00:55:46,927 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 01:00:22,982 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 01:05:29,754 INFO core: Event loop thread started, running loop forever
2026-10-02 01:05:30,055 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 01:05:30,061 INFO core: _init_accounts coroutine started
2026-10-02 01:05:30,061 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 01:05:30,067 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 01:10:23,494 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 01:15:37,161 INFO core: Event loop thread started, running loop forever
2026-10-02 01:15:37,473 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 01:15:37,482 INFO core: _init_accounts coroutine started
2026-10-02 01:15:37,483 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 01:15:37,497 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 01:20:36,382 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 01:25:18,542 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-02 01:25:18,543 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-02 01:25:18,545 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-02 01:25:18,547 INFO core: _init_accounts_inner: reloading LLM config
2026-10-02 01:25:18,547 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 01:30:04,975 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-10-02 01:30:04,976 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-10-02 01:30:04,984 INFO core: Account 2: connecting to Telegram via 91.108.56.178...
2026-10-02 01:30:04,992 INFO telethon.network.mtprotosender: Connecting to 91.108.56.178:443/TcpAbridged...
2026-10-02 01:30:05,003 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 01:35:11,385 WARNING telethon.network.mtprotosender: Attempt 1 at connecting failed: TimeoutError: 
2026-10-02 01:35:34,256 INFO core: Event loop thread started, running loop forever
2026-10-02 01:35:34,557 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 01:35:34,561 INFO core: _init_accounts coroutine started
2026-10-02 01:35:34,563 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 01:35:34,571 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 01:40:35,379 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-10-02 01:40:35,385 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 01:45:32,962 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 01:50:40,567 INFO core: Event loop thread started, running loop forever
2026-10-02 01:50:40,868 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 01:50:40,872 INFO core: _init_accounts coroutine started
2026-10-02 01:50:40,873 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 01:50:40,879 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 01:55:47,402 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-10-02 01:55:53,170 INFO core: Event loop thread started, running loop forever
2026-10-02 01:55:53,471 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 01:55:53,477 INFO core: _init_accounts coroutine started
2026-10-02 01:55:53,477 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 01:55:53,484 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-02 01:55:53,485 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-02 01:55:53,486 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-02 01:55:53,488 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 02:00:43,857 INFO core: _init_accounts_inner: reloading LLM config
2026-10-02 02:00:43,874 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 02:05:24,128 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 02:10:22,195 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 02:15:31,049 INFO core: Event loop thread started, running loop forever
2026-10-02 02:15:31,350 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 02:15:31,354 INFO core: _init_accounts coroutine started
2026-10-02 02:15:31,354 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 02:15:31,374 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-02 02:15:31,374 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-02 02:15:31,376 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 02:20:24,255 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-02 02:20:24,258 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 02:20:24,259 INFO core: _init_accounts_inner: reloading LLM config
2026-10-02 02:25:46,788 INFO core: Event loop thread started, running loop forever
2026-10-02 02:25:47,089 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 02:25:47,095 INFO core: _init_accounts coroutine started
2026-10-02 02:25:47,095 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 02:25:47,103 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 02:30:36,690 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 02:35:25,345 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 149, in _init_accounts_inner
    await self._run_db(self.db.migrate_legacy_session)
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 687, in migrate_legacy_session
    with self._conn() as conn:
         ~~~~~~~~~~^^
  File "/opt/alt/python313/lib64/python3.13/contextlib.py", line 141, in __enter__
    return next(self.gen)
  File "/home/wovewbge/quill.nx.kg/db.py", line 59, in _conn
    conn = _pool.connect()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 448, in connect
    return _ConnectionFairy._checkout(self)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 1272, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 717, in checkout
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 715, in checkout
    dbapi_connection = rec.get_connection()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 866, in get_connection
    self.__connect()
    ~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 900, in __connect
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 896, in __connect
    self.dbapi_connection = connection = pool._invoke_creator(self)
                                         ~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 361, in <lambda>
    return lambda rec: creator_fn()
                       ~~~~~~~~~~^^
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-10-02 02:35:25,353 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 02:40:42,769 INFO core: Event loop thread started, running loop forever
2026-10-02 02:40:43,070 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 02:40:43,074 INFO core: _init_accounts coroutine started
2026-10-02 02:40:43,076 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 02:40:43,090 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 02:45:40,528 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 02:50:13,834 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 02:55:41,422 INFO core: Event loop thread started, running loop forever
2026-10-02 02:55:41,724 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 02:55:41,732 INFO core: _init_accounts coroutine started
2026-10-02 02:55:41,732 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 02:55:41,750 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 03:00:52,971 INFO core: Event loop thread started, running loop forever
2026-10-02 03:00:53,273 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 03:00:53,280 INFO core: _init_accounts coroutine started
2026-10-02 03:00:53,280 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 03:00:53,284 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 03:05:06,716 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 03:10:03,699 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-10-02 03:10:03,720 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 03:15:23,979 INFO core: Event loop thread started, running loop forever
2026-10-02 03:15:24,281 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 03:15:24,291 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 03:15:24,293 INFO core: _init_accounts coroutine started
2026-10-02 03:20:26,408 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 03:20:26,432 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-02 03:20:26,432 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-02 03:20:26,433 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-02 03:20:26,434 INFO core: _init_accounts_inner: reloading LLM config
2026-10-02 03:20:26,437 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 03:25:35,638 INFO core: Event loop thread started, running loop forever
2026-10-02 03:25:35,941 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 03:25:35,950 INFO core: _init_accounts coroutine started
2026-10-02 03:25:35,951 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 03:25:35,965 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-02 03:25:35,966 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-02 03:25:35,967 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-02 03:25:35,971 INFO core: _init_accounts_inner: reloading LLM config
2026-10-02 03:25:35,971 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 03:30:18,803 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 03:35:48,691 INFO core: Event loop thread started, running loop forever
2026-10-02 03:35:48,992 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 03:35:48,996 INFO core: _init_accounts coroutine started
2026-10-02 03:35:48,997 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 03:35:49,003 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 03:40:06,900 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-10-02 03:40:06,906 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 03:45:04,178 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 03:50:38,914 INFO core: Event loop thread started, running loop forever
2026-10-02 03:50:39,215 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 03:50:39,219 INFO core: _init_accounts coroutine started
2026-10-02 03:50:39,221 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 03:50:39,227 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 03:55:43,525 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-02 03:55:43,525 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-02 03:55:43,526 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-02 03:55:43,528 INFO core: _init_accounts_inner: reloading LLM config
2026-10-02 03:55:43,531 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 04:00:40,914 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 04:05:12,053 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-10-02 04:05:12,056 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-10-02 04:05:12,065 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 04:10:09,291 INFO core: Account 2: connecting to Telegram via 91.108.56.178...
2026-10-02 04:10:09,299 INFO telethon.network.mtprotosender: Connecting to 91.108.56.178:443/TcpAbridged...
2026-10-02 04:10:09,298 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 04:15:15,611 WARNING telethon.network.mtprotosender: Attempt 1 at connecting failed: TimeoutError: 
2026-10-02 04:15:15,611 WARNING core: Account 2: connect timed out after 35s
2026-10-02 04:15:16,250 INFO core: Event loop thread started, running loop forever
2026-10-02 04:15:16,551 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 04:15:16,555 INFO core: _init_accounts coroutine started
2026-10-02 04:15:16,555 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 04:15:16,563 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 04:20:22,902 INFO core: Event loop thread started, running loop forever
2026-10-02 04:20:22,893 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-10-02 04:20:23,204 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 04:20:23,211 INFO core: _init_accounts coroutine started
2026-10-02 04:20:23,212 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 04:20:23,216 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 04:25:15,917 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-02 04:25:15,917 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-02 04:25:15,924 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-02 04:25:15,927 INFO core: _init_accounts_inner: reloading LLM config
2026-10-02 04:25:15,938 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 04:30:21,513 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-10-02 04:30:21,517 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-10-02 04:30:40,426 INFO core: Event loop thread started, running loop forever
2026-10-02 04:30:40,727 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 04:30:40,731 INFO core: _init_accounts coroutine started
2026-10-02 04:30:40,734 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 04:30:40,739 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 04:35:28,883 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-02 04:35:28,886 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-02 04:35:28,887 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 04:35:28,888 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-02 04:40:38,555 INFO core: Event loop thread started, running loop forever
2026-10-02 04:40:38,864 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 04:40:38,868 INFO core: _init_accounts coroutine started
2026-10-02 04:40:38,869 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 04:40:38,888 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 04:45:39,496 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-02 04:45:39,497 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 04:45:39,497 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-02 04:50:43,732 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-02 04:50:43,736 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 04:50:43,737 INFO core: _init_accounts_inner: reloading LLM config
2026-10-02 04:55:15,518 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 05:00:35,655 INFO core: Event loop thread started, running loop forever
2026-10-02 05:00:35,958 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 05:00:35,965 INFO core: _init_accounts coroutine started
2026-10-02 05:00:35,967 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 05:00:35,975 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 05:05:39,038 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-02 05:05:39,039 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-02 05:05:39,059 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-02 05:05:39,061 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 05:10:51,775 INFO core: Event loop thread started, running loop forever
2026-10-02 05:10:52,076 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 05:10:52,080 INFO core: _init_accounts coroutine started
2026-10-02 05:10:52,083 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 05:10:52,089 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 05:15:04,337 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-10-02 05:15:45,018 INFO core: Event loop thread started, running loop forever
2026-10-02 05:15:45,319 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 05:15:45,322 INFO core: _init_accounts coroutine started
2026-10-02 05:15:45,323 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 05:15:45,328 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 05:20:51,907 INFO core: Event loop thread started, running loop forever
2026-10-02 05:20:52,208 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 05:20:52,211 INFO core: _init_accounts coroutine started
2026-10-02 05:20:52,212 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 05:20:52,217 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 05:25:07,242 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-02 05:25:07,246 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-02 05:25:07,243 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 05:30:13,438 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-02 05:30:24,413 INFO core: Event loop thread started, running loop forever
2026-10-02 05:30:24,715 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 05:30:24,719 INFO core: _init_accounts coroutine started
2026-10-02 05:30:24,724 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 05:30:24,736 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 05:35:50,811 INFO core: Event loop thread started, running loop forever
2026-10-02 05:35:51,112 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 05:35:51,116 INFO core: _init_accounts coroutine started
2026-10-02 05:35:51,118 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 05:35:51,124 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 05:40:50,870 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-02 05:40:50,870 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-02 05:40:50,872 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-02 05:40:50,874 INFO core: _init_accounts_inner: reloading LLM config
2026-10-02 05:40:50,889 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 05:45:27,934 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-10-02 05:45:27,934 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-10-02 05:45:27,940 INFO core: Account 2: connecting to Telegram via 91.108.56.178...
2026-10-02 05:45:27,941 INFO telethon.network.mtprotosender: Connecting to 91.108.56.178:443/TcpAbridged...
2026-10-02 05:45:27,956 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 05:50:26,022 WARNING telethon.network.mtprotosender: Attempt 1 at connecting failed: TimeoutError: 
2026-10-02 05:50:26,026 WARNING core: Account 2: connect timed out after 35s
2026-10-02 05:50:26,026 INFO telethon.network.mtprotosender: Disconnecting from 91.108.56.178:443/TcpAbridged...
2026-10-02 05:50:26,026 INFO telethon.network.mtprotosender: Disconnection from 91.108.56.178:443/TcpAbridged complete!
2026-10-02 05:50:26,027 INFO telethon.network.mtprotosender: Not disconnecting (already have no connection)
2026-10-02 05:50:26,028 INFO core: Account 2: connecting to Telegram via 91.108.56.181...
2026-10-02 05:50:26,028 INFO telethon.network.mtprotosender: Connecting to 91.108.56.181:443/TcpAbridged...
2026-10-02 05:50:26,036 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 05:55:33,427 WARNING telethon.network.mtprotosender: Attempt 1 at connecting failed: TimeoutError: 
2026-10-02 05:55:33,428 WARNING core: Account 2: connect timed out after 35s
2026-10-02 05:55:33,428 INFO telethon.network.mtprotosender: Disconnecting from 91.108.56.181:443/TcpAbridged...
2026-10-02 05:55:33,428 INFO telethon.network.mtprotosender: Disconnection from 91.108.56.181:443/TcpAbridged complete!
2026-10-02 05:55:33,429 INFO telethon.network.mtprotosender: Not disconnecting (already have no connection)
2026-10-02 05:55:33,429 INFO core: Account 2: connecting to Telegram via 91.108.56.182...
2026-10-02 05:55:33,430 INFO telethon.network.mtprotosender: Connecting to 91.108.56.182:443/TcpAbridged...
2026-10-02 05:55:35,504 INFO core: Event loop thread started, running loop forever
2026-10-02 05:55:35,806 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 05:55:35,812 INFO core: _init_accounts coroutine started
2026-10-02 05:55:35,813 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 05:55:35,825 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 06:00:37,954 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-10-02 06:00:37,961 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 06:05:51,701 INFO core: Event loop thread started, running loop forever
2026-10-02 06:05:52,007 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 06:05:52,012 INFO core: _init_accounts coroutine started
2026-10-02 06:05:52,013 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 06:05:52,030 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 06:10:33,991 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 06:15:40,393 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 149, in _init_accounts_inner
    await self._run_db(self.db.migrate_legacy_session)
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-10-02 06:15:42,455 INFO core: Event loop thread started, running loop forever
2026-10-02 06:15:42,758 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 06:15:42,768 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 06:15:42,770 INFO core: _init_accounts coroutine started
2026-10-02 06:20:41,000 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 06:20:41,010 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 06:25:09,753 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-02 06:25:09,753 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-02 06:25:09,758 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-02 06:25:09,760 INFO core: _init_accounts_inner: reloading LLM config
2026-10-02 06:25:09,764 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 06:30:16,477 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-10-02 06:30:16,477 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-10-02 06:30:19,535 INFO core: Event loop thread started, running loop forever
2026-10-02 06:30:19,836 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 06:30:19,840 INFO core: _init_accounts coroutine started
2026-10-02 06:30:19,842 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 06:30:19,846 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 06:35:43,533 INFO core: Event loop thread started, running loop forever
2026-10-02 06:35:43,834 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 06:35:43,837 INFO core: _init_accounts coroutine started
2026-10-02 06:35:43,839 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 06:35:43,853 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 06:40:07,198 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 06:45:14,355 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-10-02 06:45:48,231 INFO core: Event loop thread started, running loop forever
2026-10-02 06:45:48,532 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 06:45:48,535 INFO core: _init_accounts coroutine started
2026-10-02 06:45:48,538 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 06:45:48,544 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 06:50:17,602 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-10-02 06:50:17,614 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 06:55:25,317 INFO core: Event loop thread started, running loop forever
2026-10-02 06:55:25,619 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 06:55:25,623 INFO core: _init_accounts coroutine started
2026-10-02 06:55:25,624 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 06:55:25,637 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 07:00:16,461 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-02 07:00:16,461 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-02 07:00:16,463 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 07:05:12,103 INFO core: Event loop thread started, running loop forever
2026-10-02 07:05:12,410 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 07:05:12,413 INFO core: _init_accounts coroutine started
2026-10-02 07:05:12,415 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 07:05:12,426 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 07:10:26,498 INFO core: Event loop thread started, running loop forever
2026-10-02 07:10:26,799 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 07:10:26,802 INFO core: _init_accounts coroutine started
2026-10-02 07:10:26,804 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 07:10:26,809 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 07:15:27,992 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 07:20:29,489 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-02 07:20:29,490 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-02 07:20:29,496 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 07:25:10,928 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-02 07:25:10,931 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 07:30:04,396 INFO core: _init_accounts_inner: reloading LLM config
2026-10-02 07:30:04,397 WARNING core: LLM config load failed: cannot schedule new futures after shutdown
2026-10-02 07:30:04,398 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-10-02 07:30:04,398 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 180, in _init_accounts_inner
    await self._start_account_client(acct["id"])
  File "/home/wovewbge/quill.nx.kg/core.py", line 236, in _start_account_client
    session_str = await self._run_db(self.db.get_account_session, account_id)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-10-02 07:30:09,939 INFO core: Event loop thread started, running loop forever
2026-10-02 07:30:10,241 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 07:30:10,250 INFO core: _init_accounts coroutine started
2026-10-02 07:30:10,250 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 07:30:10,253 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 07:35:20,439 INFO core: Event loop thread started, running loop forever
2026-10-02 07:35:20,741 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 07:35:20,751 INFO core: _init_accounts coroutine started
2026-10-02 07:35:20,751 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 07:35:20,758 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 07:40:26,279 INFO core: Event loop thread started, running loop forever
2026-10-02 07:40:26,580 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 07:40:26,584 INFO core: _init_accounts coroutine started
2026-10-02 07:40:26,586 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 07:40:26,592 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 07:45:32,440 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-02 07:45:32,441 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-02 07:45:32,441 WARNING core: ensure_llm_schema failed: cannot schedule new futures after shutdown
2026-10-02 07:45:32,442 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-02 07:45:32,442 WARNING core: ensure_pair_schema failed: cannot schedule new futures after shutdown
2026-10-02 07:45:32,442 INFO core: _init_accounts_inner: reloading LLM config
2026-10-02 07:45:32,442 WARNING core: LLM config load failed: cannot schedule new futures after shutdown
2026-10-02 07:45:32,443 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-10-02 07:45:32,443 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 180, in _init_accounts_inner
    await self._start_account_client(acct["id"])
  File "/home/wovewbge/quill.nx.kg/core.py", line 236, in _start_account_client
    session_str = await self._run_db(self.db.get_account_session, account_id)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-10-02 07:45:44,534 INFO core: Event loop thread started, running loop forever
2026-10-02 07:45:44,835 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 07:45:44,838 INFO core: _init_accounts coroutine started
2026-10-02 07:45:44,838 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 07:45:44,850 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 07:50:52,721 INFO core: Event loop thread started, running loop forever
2026-10-02 07:50:53,028 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 07:50:53,032 INFO core: _init_accounts coroutine started
2026-10-02 07:50:53,033 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 07:50:53,040 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 07:55:12,185 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 08:00:10,759 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-02 08:00:10,761 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-02 08:00:10,766 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 08:05:16,419 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-02 08:05:16,420 WARNING core: ensure_pair_schema failed: cannot schedule new futures after shutdown
2026-10-02 08:05:16,421 INFO core: _init_accounts_inner: reloading LLM config
2026-10-02 08:05:16,421 WARNING core: LLM config load failed: cannot schedule new futures after shutdown
2026-10-02 08:05:16,421 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-10-02 08:05:16,421 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 180, in _init_accounts_inner
    await self._start_account_client(acct["id"])
  File "/home/wovewbge/quill.nx.kg/core.py", line 236, in _start_account_client
    session_str = await self._run_db(self.db.get_account_session, account_id)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-10-02 08:05:45,047 INFO core: Event loop thread started, running loop forever
2026-10-02 08:05:45,348 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 08:05:45,352 INFO core: _init_accounts coroutine started
2026-10-02 08:05:45,354 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 08:05:45,362 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-02 08:05:45,362 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-02 08:05:45,363 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 08:10:36,022 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-02 08:10:36,028 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 08:15:38,535 INFO core: Event loop thread started, running loop forever
2026-10-02 08:15:38,841 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 08:15:38,845 INFO core: _init_accounts coroutine started
2026-10-02 08:15:38,852 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 08:15:38,858 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 08:15:43,538 INFO core: _init_accounts_inner: reloading LLM config
2026-10-02 08:20:37,087 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-10-02 08:20:37,097 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 08:25:35,156 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 08:30:33,761 INFO app: Retrying account initialization (clients=0 but authorized accounts in DB)
2026-10-02 08:30:33,762 INFO core: _init_accounts coroutine started
2026-10-02 08:30:33,762 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 08:30:33,766 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 08:35:46,155 INFO core: Event loop thread started, running loop forever
2026-10-02 08:35:46,458 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 08:35:46,463 INFO core: _init_accounts coroutine started
2026-10-02 08:35:46,463 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 08:35:46,469 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 08:40:29,800 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 126, in _init_accounts_inner
    accounts = await self._run_db(self.db.get_accounts)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 540, in get_accounts
    with self._conn() as conn:
         ~~~~~~~~~~^^
  File "/opt/alt/python313/lib64/python3.13/contextlib.py", line 141, in __enter__
    return next(self.gen)
  File "/home/wovewbge/quill.nx.kg/db.py", line 59, in _conn
    conn = _pool.connect()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 448, in connect
    return _ConnectionFairy._checkout(self)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 1272, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 712, in checkout
    rec = pool._do_get()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/impl.py", line 178, in _do_get
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/impl.py", line 176, in _do_get
    return self._create_connection()
           ~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection
    return _ConnectionRecord(self)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 674, in __init__
    self.__connect()
    ~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 900, in __connect
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 896, in __connect
    self.dbapi_connection = connection = pool._invoke_creator(self)
                                         ~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 361, in <lambda>
    return lambda rec: creator_fn()
                       ~~~~~~~~~~^^
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-10-02 08:40:29,807 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 08:45:10,659 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 08:50:33,847 INFO core: Event loop thread started, running loop forever
2026-10-02 08:50:34,151 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 08:50:34,154 INFO core: _init_accounts coroutine started
2026-10-02 08:50:34,156 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 08:50:34,161 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 08:55:14,507 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-10-02 08:55:14,521 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 09:00:50,834 INFO core: Event loop thread started, running loop forever
2026-10-02 09:00:51,135 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 09:00:51,138 INFO core: _init_accounts coroutine started
2026-10-02 09:00:51,139 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 09:00:51,148 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 09:05:07,821 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 09:10:22,591 INFO core: Event loop thread started, running loop forever
2026-10-02 09:10:22,892 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 09:10:22,897 INFO core: _init_accounts coroutine started
2026-10-02 09:10:22,899 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 09:10:22,904 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 09:15:22,085 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 09:20:23,473 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-02 09:20:23,474 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-02 09:20:23,482 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-02 09:20:23,484 INFO core: _init_accounts_inner: reloading LLM config
2026-10-02 09:20:23,488 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 09:25:17,430 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 09:30:18,810 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 09:30:18,813 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-10-02 09:35:14,346 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-10-02 09:35:14,354 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 09:40:21,398 INFO core: Account 2: connecting to Telegram via 91.108.56.178...
2026-10-02 09:40:46,816 INFO core: Event loop thread started, running loop forever
2026-10-02 09:40:47,119 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 09:40:47,125 INFO core: _init_accounts coroutine started
2026-10-02 09:40:47,129 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 09:40:47,134 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 09:45:41,582 INFO core: Event loop thread started, running loop forever
2026-10-02 09:45:41,883 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 09:45:41,887 INFO core: _init_accounts coroutine started
2026-10-02 09:45:41,887 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 09:45:41,892 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 09:50:28,697 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 09:55:34,874 INFO core: Event loop thread started, running loop forever
2026-10-02 09:55:35,175 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 09:55:35,178 INFO core: _init_accounts coroutine started
2026-10-02 09:55:35,179 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 09:55:35,185 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 10:00:28,509 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 10:05:48,383 INFO core: Event loop thread started, running loop forever
2026-10-02 10:05:48,684 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 10:05:48,694 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 10:10:45,888 INFO core: _init_accounts coroutine started
2026-10-02 10:10:45,890 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 10:10:45,894 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 10:15:32,504 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 10:20:12,121 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-10-02 10:20:12,127 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 10:25:12,326 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 10:30:09,182 INFO app: Retrying account initialization (clients=0 but authorized accounts in DB)
2026-10-02 10:30:09,184 INFO core: _init_accounts coroutine started
2026-10-02 10:30:09,184 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 10:30:09,193 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 10:35:52,113 INFO core: Event loop thread started, running loop forever
2026-10-02 10:35:52,414 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 10:35:52,418 INFO core: _init_accounts coroutine started
2026-10-02 10:35:52,420 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 10:35:52,425 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 10:40:10,365 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-02 10:40:10,366 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-02 10:40:10,367 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-02 10:40:10,368 INFO core: _init_accounts_inner: reloading LLM config
2026-10-02 10:40:10,373 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 10:45:12,994 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 10:50:07,786 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 10:55:13,415 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-10-02 10:55:13,416 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-10-02 10:55:26,443 INFO core: Event loop thread started, running loop forever
2026-10-02 10:55:26,744 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 10:55:26,750 INFO core: _init_accounts coroutine started
2026-10-02 10:55:26,751 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 10:55:26,757 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 11:00:39,593 INFO core: Event loop thread started, running loop forever
2026-10-02 11:00:39,894 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 11:00:39,898 INFO core: _init_accounts coroutine started
2026-10-02 11:00:39,899 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 11:00:39,932 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-02 11:00:39,933 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-02 11:00:39,933 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 11:00:39,935 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-02 11:05:45,634 INFO core: Event loop thread started, running loop forever
2026-10-02 11:05:45,935 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 11:05:45,939 INFO core: _init_accounts coroutine started
2026-10-02 11:05:45,940 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 11:05:45,952 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 11:10:50,816 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-02 11:10:50,816 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 11:10:50,816 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-02 11:15:38,725 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 11:20:44,387 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-02 11:20:44,403 INFO core: _init_accounts_inner: reloading LLM config
2026-10-02 11:20:44,404 WARNING core: LLM config load failed: cannot schedule new futures after shutdown
2026-10-02 11:20:44,404 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-10-02 11:20:44,405 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 180, in _init_accounts_inner
    await self._start_account_client(acct["id"])
  File "/home/wovewbge/quill.nx.kg/core.py", line 236, in _start_account_client
    session_str = await self._run_db(self.db.get_account_session, account_id)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-10-02 11:20:52,866 INFO core: Event loop thread started, running loop forever
2026-10-02 11:20:53,168 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 11:20:53,171 INFO core: _init_accounts coroutine started
2026-10-02 11:20:53,172 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 11:20:53,182 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-02 11:20:53,182 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-02 11:20:53,183 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-02 11:20:53,184 INFO core: _init_accounts_inner: reloading LLM config
2026-10-02 11:20:53,189 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 11:25:50,426 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 11:30:49,102 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-10-02 11:30:49,103 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-10-02 11:30:49,113 INFO core: Account 2: connecting to Telegram via 91.108.56.178...
2026-10-02 11:30:49,116 INFO telethon.network.mtprotosender: Connecting to 91.108.56.178:443/TcpAbridged...
2026-10-02 11:30:49,117 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 11:35:32,595 WARNING telethon.network.mtprotosender: Attempt 1 at connecting failed: TimeoutError: 
2026-10-02 11:35:32,595 WARNING core: Account 2: connect timed out after 35s
2026-10-02 11:35:32,596 INFO telethon.network.mtprotosender: Disconnecting from 91.108.56.178:443/TcpAbridged...
2026-10-02 11:35:32,596 INFO telethon.network.mtprotosender: Disconnection from 91.108.56.178:443/TcpAbridged complete!
2026-10-02 11:35:32,597 INFO telethon.network.mtprotosender: Not disconnecting (already have no connection)
2026-10-02 11:35:32,598 INFO core: Account 2: connecting to Telegram via 91.108.56.181...
2026-10-02 11:35:32,598 INFO telethon.network.mtprotosender: Connecting to 91.108.56.181:443/TcpAbridged...
2026-10-02 11:35:32,600 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 11:40:36,188 WARNING telethon.network.mtprotosender: Attempt 1 at connecting failed: TimeoutError: 
2026-10-02 11:40:36,188 WARNING core: Account 2: connect timed out after 35s
2026-10-02 11:40:36,188 INFO telethon.network.mtprotosender: Disconnecting from 91.108.56.181:443/TcpAbridged...
2026-10-02 11:40:36,189 INFO telethon.network.mtprotosender: Disconnection from 91.108.56.181:443/TcpAbridged complete!
2026-10-02 11:40:36,189 INFO telethon.network.mtprotosender: Not disconnecting (already have no connection)
2026-10-02 11:40:36,189 INFO core: Account 2: connecting to Telegram via 91.108.56.182...
2026-10-02 11:40:36,190 INFO telethon.network.mtprotosender: Connecting to 91.108.56.182:443/TcpAbridged...
2026-10-02 11:40:36,196 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 11:45:43,389 WARNING telethon.network.mtprotosender: Attempt 1 at connecting failed: TimeoutError: 
2026-10-02 11:45:48,250 INFO core: Event loop thread started, running loop forever
2026-10-02 11:45:48,555 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 11:45:48,561 INFO core: _init_accounts coroutine started
2026-10-02 11:45:48,562 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 11:45:48,567 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 11:50:43,059 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 11:55:17,223 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 11:55:17,224 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-02 12:00:05,410 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-02 12:00:05,458 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-02 12:00:05,458 WARNING core: ensure_pair_schema failed: cannot schedule new futures after shutdown
2026-10-02 12:00:05,459 INFO core: _init_accounts_inner: reloading LLM config
2026-10-02 12:00:05,459 WARNING core: LLM config load failed: cannot schedule new futures after shutdown
2026-10-02 12:00:05,459 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-10-02 12:00:05,459 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 180, in _init_accounts_inner
    await self._start_account_client(acct["id"])
  File "/home/wovewbge/quill.nx.kg/core.py", line 236, in _start_account_client
    session_str = await self._run_db(self.db.get_account_session, account_id)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-10-02 12:00:47,762 INFO core: Event loop thread started, running loop forever
2026-10-02 12:00:48,067 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 12:00:48,070 INFO core: _init_accounts coroutine started
2026-10-02 12:00:48,072 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 12:00:48,077 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 12:00:48,090 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-02 12:05:10,827 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-02 12:05:10,832 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-02 12:05:10,835 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 12:05:10,835 INFO core: _init_accounts_inner: reloading LLM config
2026-10-02 12:10:48,117 INFO core: Event loop thread started, running loop forever
2026-10-02 12:10:48,428 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 12:10:48,439 INFO core: _init_accounts coroutine started
2026-10-02 12:10:48,439 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 12:10:48,447 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 12:15:52,601 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 12:20:50,984 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 12:25:03,997 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-02 12:25:03,998 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-02 12:25:04,004 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 12:30:11,194 INFO core: Event loop thread started, running loop forever
2026-10-02 12:30:11,497 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 12:30:11,504 INFO core: _init_accounts coroutine started
2026-10-02 12:30:11,504 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 12:30:11,518 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 12:35:09,687 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 12:40:03,926 INFO app: Retrying account initialization (clients=0 but authorized accounts in DB)
2026-10-02 12:40:03,928 INFO core: _init_accounts coroutine started
2026-10-02 12:40:03,928 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 12:40:03,936 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 12:45:27,348 INFO core: Event loop thread started, running loop forever
2026-10-02 12:45:27,651 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 12:45:27,654 INFO core: _init_accounts coroutine started
2026-10-02 12:45:27,660 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 12:45:27,664 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 12:50:34,431 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 126, in _init_accounts_inner
    accounts = await self._run_db(self.db.get_accounts)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 540, in get_accounts
    with self._conn() as conn:
         ~~~~~~~~~~^^
  File "/opt/alt/python313/lib64/python3.13/contextlib.py", line 141, in __enter__
    return next(self.gen)
  File "/home/wovewbge/quill.nx.kg/db.py", line 59, in _conn
    conn = _pool.connect()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 448, in connect
    return _ConnectionFairy._checkout(self)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 1272, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 712, in checkout
    rec = pool._do_get()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/impl.py", line 178, in _do_get
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/impl.py", line 176, in _do_get
    return self._create_connection()
           ~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection
    return _ConnectionRecord(self)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 674, in __init__
    self.__connect()
    ~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 900, in __connect
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 896, in __connect
    self.dbapi_connection = connection = pool._invoke_creator(self)
                                         ~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 361, in <lambda>
    return lambda rec: creator_fn()
                       ~~~~~~~~~~^^
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-10-02 12:50:51,909 INFO core: Event loop thread started, running loop forever
2026-10-02 12:50:52,211 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 12:50:52,215 INFO core: _init_accounts coroutine started
2026-10-02 12:50:52,216 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 12:50:52,225 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 12:55:04,762 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-10-02 12:55:04,771 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 13:00:19,460 INFO core: Event loop thread started, running loop forever
2026-10-02 13:00:19,765 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 13:00:19,769 INFO core: _init_accounts coroutine started
2026-10-02 13:00:19,769 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 13:00:19,785 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 13:05:21,763 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-10-02 13:05:21,776 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 13:10:37,952 INFO core: Event loop thread started, running loop forever
2026-10-02 13:10:38,262 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 13:10:38,271 INFO core: _init_accounts coroutine started
2026-10-02 13:10:38,282 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 13:10:38,274 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 13:15:28,501 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-10-02 13:15:28,515 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 13:20:48,870 INFO core: Event loop thread started, running loop forever
2026-10-02 13:20:49,171 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 13:20:49,176 INFO core: _init_accounts coroutine started
2026-10-02 13:20:49,177 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 13:20:49,184 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 13:25:14,189 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-02 13:25:14,189 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-02 13:25:14,190 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-02 13:25:14,191 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 13:30:21,452 INFO core: _init_accounts_inner: reloading LLM config
2026-10-02 13:30:21,453 WARNING core: LLM config load failed: cannot schedule new futures after shutdown
2026-10-02 13:30:21,453 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-10-02 13:30:21,454 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 180, in _init_accounts_inner
    await self._start_account_client(acct["id"])
  File "/home/wovewbge/quill.nx.kg/core.py", line 236, in _start_account_client
    session_str = await self._run_db(self.db.get_account_session, account_id)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-10-02 13:30:24,744 INFO core: Event loop thread started, running loop forever
2026-10-02 13:30:25,052 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 13:30:25,057 INFO core: _init_accounts coroutine started
2026-10-02 13:30:25,059 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 13:30:25,071 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 13:30:25,072 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-02 13:30:25,073 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-02 13:35:51,951 INFO core: Event loop thread started, running loop forever
2026-10-02 13:35:52,261 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 13:35:52,267 INFO core: _init_accounts coroutine started
2026-10-02 13:35:52,268 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 13:35:52,278 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 13:35:52,283 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-02 13:35:52,283 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-02 13:35:52,287 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-02 13:35:52,288 INFO core: _init_accounts_inner: reloading LLM config
2026-10-02 13:40:31,222 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 13:45:38,428 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-10-02 13:45:38,436 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-10-02 13:45:38,436 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 180, in _init_accounts_inner
    await self._start_account_client(acct["id"])
  File "/home/wovewbge/quill.nx.kg/core.py", line 236, in _start_account_client
    session_str = await self._run_db(self.db.get_account_session, account_id)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-10-02 13:45:41,550 INFO core: Event loop thread started, running loop forever
2026-10-02 13:45:41,851 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 13:45:41,856 INFO core: _init_accounts coroutine started
2026-10-02 13:45:41,856 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 13:45:41,875 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 13:50:31,661 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-02 13:50:31,661 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-02 13:50:31,662 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-02 13:50:31,664 INFO core: _init_accounts_inner: reloading LLM config
2026-10-02 13:50:31,664 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 13:55:33,561 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 14:00:50,454 INFO core: Event loop thread started, running loop forever
2026-10-02 14:00:50,759 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 14:00:50,763 INFO core: _init_accounts coroutine started
2026-10-02 14:00:50,766 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 14:00:50,774 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 14:05:27,712 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 14:10:42,338 INFO core: Event loop thread started, running loop forever
2026-10-02 14:10:42,640 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 14:10:42,643 INFO core: _init_accounts coroutine started
2026-10-02 14:10:42,647 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 14:10:42,669 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 14:15:03,416 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-02 14:15:03,416 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-02 14:15:03,416 WARNING core: ensure_llm_schema failed: cannot schedule new futures after shutdown
2026-10-02 14:15:03,417 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-02 14:15:03,417 WARNING core: ensure_pair_schema failed: cannot schedule new futures after shutdown
2026-10-02 14:15:03,417 INFO core: _init_accounts_inner: reloading LLM config
2026-10-02 14:15:03,417 WARNING core: LLM config load failed: cannot schedule new futures after shutdown
2026-10-02 14:15:03,417 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-10-02 14:15:03,417 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 180, in _init_accounts_inner
    await self._start_account_client(acct["id"])
  File "/home/wovewbge/quill.nx.kg/core.py", line 236, in _start_account_client
    session_str = await self._run_db(self.db.get_account_session, account_id)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-10-02 14:15:21,926 INFO core: Event loop thread started, running loop forever
2026-10-02 14:15:22,227 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 14:15:22,231 INFO core: _init_accounts coroutine started
2026-10-02 14:15:22,231 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 14:15:22,238 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 14:20:04,568 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-02 14:20:04,568 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-02 14:20:04,570 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-02 14:20:04,573 INFO core: _init_accounts_inner: reloading LLM config
2026-10-02 14:20:04,578 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 14:25:45,813 INFO core: Event loop thread started, running loop forever
2026-10-02 14:25:46,115 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 14:25:46,118 INFO core: _init_accounts coroutine started
2026-10-02 14:25:46,119 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 14:25:46,127 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 14:30:36,305 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 14:35:27,893 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-02 14:35:27,894 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-02 14:35:27,899 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-02 14:35:27,900 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 14:40:33,371 INFO core: _init_accounts_inner: reloading LLM config
2026-10-02 14:40:33,371 WARNING core: LLM config load failed: cannot schedule new futures after shutdown
2026-10-02 14:40:33,371 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-10-02 14:40:33,372 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 180, in _init_accounts_inner
    await self._start_account_client(acct["id"])
  File "/home/wovewbge/quill.nx.kg/core.py", line 236, in _start_account_client
    session_str = await self._run_db(self.db.get_account_session, account_id)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-10-02 14:40:49,313 INFO core: Event loop thread started, running loop forever
2026-10-02 14:40:49,614 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 14:40:49,617 INFO core: _init_accounts coroutine started
2026-10-02 14:40:49,617 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 14:40:49,629 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 14:45:52,634 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-10-02 14:45:52,658 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 14:50:49,041 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 14:55:28,481 INFO app: Retrying account initialization (clients=0 but authorized accounts in DB)
2026-10-02 14:55:28,482 INFO core: _init_accounts coroutine started
2026-10-02 14:55:28,482 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 14:55:28,486 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 15:00:50,321 INFO core: Event loop thread started, running loop forever
2026-10-02 15:00:50,622 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 15:00:50,624 INFO core: _init_accounts coroutine started
2026-10-02 15:00:50,626 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 15:00:50,632 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 15:05:31,575 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 15:10:14,991 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 149, in _init_accounts_inner
    await self._run_db(self.db.migrate_legacy_session)
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 687, in migrate_legacy_session
    with self._conn() as conn:
         ~~~~~~~~~~^^
  File "/opt/alt/python313/lib64/python3.13/contextlib.py", line 141, in __enter__
    return next(self.gen)
  File "/home/wovewbge/quill.nx.kg/db.py", line 59, in _conn
    conn = _pool.connect()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 448, in connect
    return _ConnectionFairy._checkout(self)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 1272, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 717, in checkout
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 715, in checkout
    dbapi_connection = rec.get_connection()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 866, in get_connection
    self.__connect()
    ~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 900, in __connect
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 896, in __connect
    self.dbapi_connection = connection = pool._invoke_creator(self)
                                         ~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 361, in <lambda>
    return lambda rec: creator_fn()
                       ~~~~~~~~~~^^
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-10-02 15:10:14,997 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 15:15:50,114 INFO core: Event loop thread started, running loop forever
2026-10-02 15:15:50,415 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 15:15:50,418 INFO core: _init_accounts coroutine started
2026-10-02 15:15:50,420 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 15:15:50,425 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 15:20:24,384 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-02 15:20:24,385 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-02 15:20:24,387 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 15:25:20,262 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-02 15:25:20,266 INFO core: _init_accounts_inner: reloading LLM config
2026-10-02 15:25:20,267 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 15:30:09,574 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 15:35:15,417 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-10-02 15:35:15,417 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-10-02 15:35:29,708 INFO core: Event loop thread started, running loop forever
2026-10-02 15:35:30,014 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 15:35:30,019 INFO core: _init_accounts coroutine started
2026-10-02 15:35:30,020 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 15:35:30,027 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 15:40:05,598 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 15:45:42,048 INFO core: Event loop thread started, running loop forever
2026-10-02 15:45:42,352 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 15:45:42,357 INFO core: _init_accounts coroutine started
2026-10-02 15:45:42,358 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 15:45:42,363 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 15:50:20,433 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 15:55:45,694 INFO core: Event loop thread started, running loop forever
2026-10-02 15:55:45,995 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 15:55:46,000 INFO core: _init_accounts coroutine started
2026-10-02 15:55:46,002 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 15:55:46,010 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 16:00:37,686 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 16:05:05,783 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 16:05:05,784 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-02 16:10:11,378 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-02 16:10:21,642 INFO core: Event loop thread started, running loop forever
2026-10-02 16:10:21,943 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 16:10:21,954 INFO core: _init_accounts coroutine started
2026-10-02 16:10:21,955 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 16:10:21,965 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 16:15:31,900 INFO core: Event loop thread started, running loop forever
2026-10-02 16:15:32,201 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 16:15:32,205 INFO core: _init_accounts coroutine started
2026-10-02 16:15:32,208 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 16:15:32,214 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 16:20:07,420 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 16:25:14,362 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-02 16:25:14,363 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-02 16:25:14,363 WARNING core: ensure_llm_schema failed: cannot schedule new futures after shutdown
2026-10-02 16:25:14,364 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-02 16:25:14,364 WARNING core: ensure_pair_schema failed: cannot schedule new futures after shutdown
2026-10-02 16:25:14,364 INFO core: _init_accounts_inner: reloading LLM config
2026-10-02 16:25:14,364 WARNING core: LLM config load failed: cannot schedule new futures after shutdown
2026-10-02 16:25:14,365 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-10-02 16:25:20,495 INFO core: Event loop thread started, running loop forever
2026-10-02 16:25:20,795 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 16:25:20,803 INFO core: _init_accounts coroutine started
2026-10-02 16:25:20,803 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 16:25:20,807 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 16:30:03,343 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 126, in _init_accounts_inner
    accounts = await self._run_db(self.db.get_accounts)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 540, in get_accounts
    with self._conn() as conn:
         ~~~~~~~~~~^^
  File "/opt/alt/python313/lib64/python3.13/contextlib.py", line 141, in __enter__
    return next(self.gen)
  File "/home/wovewbge/quill.nx.kg/db.py", line 59, in _conn
    conn = _pool.connect()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 448, in connect
    return _ConnectionFairy._checkout(self)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 1272, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 712, in checkout
    rec = pool._do_get()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/impl.py", line 178, in _do_get
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/impl.py", line 176, in _do_get
    return self._create_connection()
           ~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection
    return _ConnectionRecord(self)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 674, in __init__
    self.__connect()
    ~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 900, in __connect
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 896, in __connect
    self.dbapi_connection = connection = pool._invoke_creator(self)
                                         ~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 361, in <lambda>
    return lambda rec: creator_fn()
                       ~~~~~~~~~~^^
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-10-02 16:30:50,318 INFO core: Event loop thread started, running loop forever
2026-10-02 16:30:50,619 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 16:30:50,622 INFO core: _init_accounts coroutine started
2026-10-02 16:30:50,624 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 16:30:50,631 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 16:35:27,921 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 16:40:09,800 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-02 16:40:09,800 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-02 16:40:09,802 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 16:40:09,803 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-02 16:45:22,509 INFO core: Event loop thread started, running loop forever
2026-10-02 16:45:22,810 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 16:45:22,814 INFO core: _init_accounts coroutine started
2026-10-02 16:45:22,815 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 16:45:22,822 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 16:50:24,243 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 16:55:07,058 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-10-02 16:55:07,069 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 17:00:13,952 INFO core: Event loop thread started, running loop forever
2026-10-02 17:00:14,254 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 17:00:14,260 INFO core: _init_accounts coroutine started
2026-10-02 17:00:14,260 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 17:00:14,268 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 17:05:13,130 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-10-02 17:05:13,142 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 17:10:20,865 INFO core: Event loop thread started, running loop forever
2026-10-02 17:10:21,166 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 17:10:21,172 INFO core: _init_accounts coroutine started
2026-10-02 17:10:21,173 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 17:10:21,177 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 17:15:27,461 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 149, in _init_accounts_inner
    await self._run_db(self.db.migrate_legacy_session)
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-10-02 17:15:32,517 INFO core: Event loop thread started, running loop forever
2026-10-02 17:15:32,819 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 17:15:32,829 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 17:15:32,834 INFO core: _init_accounts coroutine started
2026-10-02 17:20:38,142 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 17:20:38,154 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 17:25:28,094 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-10-02 17:25:28,107 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 17:30:08,112 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 17:35:20,606 INFO core: Event loop thread started, running loop forever
2026-10-02 17:35:20,907 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 17:35:20,911 INFO core: _init_accounts coroutine started
2026-10-02 17:35:20,912 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 17:35:20,920 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 17:40:10,651 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-10-02 17:40:10,675 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 17:45:24,508 INFO core: Event loop thread started, running loop forever
2026-10-02 17:45:24,809 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 17:45:24,814 INFO core: _init_accounts coroutine started
2026-10-02 17:45:24,815 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 17:45:24,821 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 17:50:52,559 INFO core: Event loop thread started, running loop forever
2026-10-02 17:50:52,859 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 17:50:52,864 INFO core: _init_accounts coroutine started
2026-10-02 17:50:52,865 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 17:50:52,868 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 17:55:27,950 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 18:00:20,059 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-02 18:00:20,059 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 18:00:20,060 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-02 18:05:36,819 INFO core: Event loop thread started, running loop forever
2026-10-02 18:05:37,120 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 18:05:37,124 INFO core: _init_accounts coroutine started
2026-10-02 18:05:37,126 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 18:05:37,130 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 18:10:14,518 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 18:15:37,345 INFO core: Event loop thread started, running loop forever
2026-10-02 18:15:37,670 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 18:15:37,674 INFO core: _init_accounts coroutine started
2026-10-02 18:15:37,675 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 18:15:37,679 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 18:20:25,366 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-02 18:20:25,367 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-02 18:20:25,367 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 18:25:31,712 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-02 18:25:31,715 INFO core: _init_accounts_inner: reloading LLM config
2026-10-02 18:25:31,719 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 18:30:16,294 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 18:35:23,395 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-10-02 18:35:23,396 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-10-02 18:35:33,420 INFO core: Event loop thread started, running loop forever
2026-10-02 18:35:33,721 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 18:35:33,725 INFO core: _init_accounts coroutine started
2026-10-02 18:35:33,727 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 18:35:33,735 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 18:40:39,061 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-02 18:40:39,062 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-02 18:40:39,066 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 18:45:09,456 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 18:45:09,457 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-02 18:50:08,800 INFO core: Event loop thread started, running loop forever
2026-10-02 18:50:09,101 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 18:50:09,112 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 18:50:16,797 INFO core: _init_accounts_inner: reloading LLM config
2026-10-02 18:50:16,797 WARNING core: LLM config load failed: cannot schedule new futures after shutdown
2026-10-02 18:50:16,798 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-10-02 18:50:16,798 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 180, in _init_accounts_inner
    await self._start_account_client(acct["id"])
  File "/home/wovewbge/quill.nx.kg/core.py", line 236, in _start_account_client
    session_str = await self._run_db(self.db.get_account_session, account_id)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-10-02 18:55:04,090 INFO core: _init_accounts coroutine started
2026-10-02 18:55:04,091 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 18:55:04,109 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-02 18:55:04,109 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-02 18:55:04,110 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-02 18:55:04,111 INFO core: _init_accounts_inner: reloading LLM config
2026-10-02 18:55:04,135 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 19:00:22,519 INFO core: Event loop thread started, running loop forever
2026-10-02 19:00:22,820 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 19:00:22,829 INFO core: _init_accounts coroutine started
2026-10-02 19:00:22,829 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 19:00:22,831 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 19:05:06,013 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 19:10:04,543 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-02 19:10:04,544 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-02 19:10:04,555 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 19:15:23,912 INFO core: Event loop thread started, running loop forever
2026-10-02 19:15:24,216 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 19:15:24,220 INFO core: _init_accounts coroutine started
2026-10-02 19:15:24,221 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 19:15:24,229 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 19:20:11,802 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 19:25:47,967 INFO core: Event loop thread started, running loop forever
2026-10-02 19:25:48,268 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 19:25:48,275 INFO core: _init_accounts coroutine started
2026-10-02 19:25:48,275 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 19:25:48,281 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 19:30:11,250 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 19:35:42,092 INFO core: Event loop thread started, running loop forever
2026-10-02 19:35:42,398 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 19:35:42,402 INFO core: _init_accounts coroutine started
2026-10-02 19:35:42,404 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 19:35:42,420 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 19:40:22,290 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-02 19:40:22,290 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-02 19:40:22,293 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 19:45:16,788 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-02 19:45:16,790 INFO core: _init_accounts_inner: reloading LLM config
2026-10-02 19:45:16,794 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 19:50:11,298 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 19:55:31,113 INFO core: Event loop thread started, running loop forever
2026-10-02 19:55:31,414 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 19:55:31,419 INFO core: _init_accounts coroutine started
2026-10-02 19:55:31,420 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 19:55:31,426 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 20:00:38,679 INFO core: Event loop thread started, running loop forever
2026-10-02 20:00:38,982 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 20:00:38,986 INFO core: _init_accounts coroutine started
2026-10-02 20:00:38,987 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 20:00:38,991 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 20:05:11,239 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 20:10:50,112 INFO core: Event loop thread started, running loop forever
2026-10-02 20:10:50,413 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 20:10:50,417 INFO core: _init_accounts coroutine started
2026-10-02 20:10:50,419 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 20:10:50,423 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 20:15:12,192 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 20:20:19,379 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 149, in _init_accounts_inner
    await self._run_db(self.db.migrate_legacy_session)
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-10-02 20:20:25,974 INFO core: Event loop thread started, running loop forever
2026-10-02 20:20:26,275 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 20:20:26,278 INFO core: _init_accounts coroutine started
2026-10-02 20:20:26,280 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 20:20:26,285 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 20:25:03,339 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 20:30:05,093 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-02 20:30:05,094 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-02 20:30:05,097 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-02 20:30:05,107 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 20:35:11,381 INFO core: _init_accounts_inner: reloading LLM config
2026-10-02 20:35:36,629 INFO core: Event loop thread started, running loop forever
2026-10-02 20:35:36,931 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 20:35:36,934 INFO core: _init_accounts coroutine started
2026-10-02 20:35:36,937 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 20:35:36,950 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 20:40:20,154 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 20:45:21,297 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-02 20:45:21,297 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-02 20:45:21,299 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-02 20:45:21,299 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 20:50:22,910 INFO core: _init_accounts_inner: reloading LLM config
2026-10-02 20:50:22,916 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 20:55:53,010 INFO core: Event loop thread started, running loop forever
2026-10-02 20:55:53,311 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 20:55:53,316 INFO core: _init_accounts coroutine started
2026-10-02 20:55:53,317 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 20:55:53,323 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 21:00:10,119 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 21:05:17,406 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-02 21:05:17,406 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-02 21:05:40,039 INFO core: Event loop thread started, running loop forever
2026-10-02 21:05:40,341 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 21:05:40,344 INFO core: _init_accounts coroutine started
2026-10-02 21:05:40,344 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 21:05:40,362 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 21:10:14,733 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 21:15:08,012 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 21:20:05,793 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-02 21:20:05,793 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-02 21:20:05,796 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 21:20:05,797 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-02 21:25:12,358 INFO core: _init_accounts_inner: reloading LLM config
2026-10-02 21:25:40,800 INFO core: Event loop thread started, running loop forever
2026-10-02 21:25:41,101 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 21:25:41,104 INFO core: _init_accounts coroutine started
2026-10-02 21:25:41,106 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 21:25:41,114 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 21:30:40,856 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-02 21:30:40,856 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-02 21:30:40,859 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-02 21:30:40,860 INFO core: _init_accounts_inner: reloading LLM config
2026-10-02 21:30:40,861 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 21:35:05,453 INFO core: Event loop thread started, running loop forever
2026-10-02 21:35:05,754 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 21:35:05,758 INFO core: _init_accounts coroutine started
2026-10-02 21:35:05,759 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 21:35:05,806 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 21:35:47,543 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-10-02 21:35:47,544 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-10-02 21:40:48,816 INFO core: Event loop thread started, running loop forever
2026-10-02 21:40:49,119 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 21:40:49,122 INFO core: _init_accounts coroutine started
2026-10-02 21:40:49,124 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 21:40:49,130 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 21:45:31,854 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 21:50:37,355 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 149, in _init_accounts_inner
    await self._run_db(self.db.migrate_legacy_session)
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-10-02 21:50:40,027 INFO core: Event loop thread started, running loop forever
2026-10-02 21:50:40,329 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 21:50:40,333 INFO core: _init_accounts coroutine started
2026-10-02 21:50:40,335 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 21:50:40,342 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 21:55:19,817 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-02 21:55:19,818 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-02 21:55:19,818 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 22:00:25,540 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-02 22:00:25,549 INFO core: _init_accounts_inner: reloading LLM config
2026-10-02 22:00:25,552 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 22:05:50,498 INFO core: Event loop thread started, running loop forever
2026-10-02 22:05:50,802 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 22:05:50,807 INFO core: _init_accounts coroutine started
2026-10-02 22:05:50,807 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 22:05:50,812 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 22:10:47,955 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 22:15:11,328 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 22:20:18,424 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-02 22:20:18,424 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-02 22:20:18,425 WARNING core: ensure_llm_schema failed: cannot schedule new futures after shutdown
2026-10-02 22:20:18,425 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-02 22:20:18,425 WARNING core: ensure_pair_schema failed: cannot schedule new futures after shutdown
2026-10-02 22:20:18,425 INFO core: _init_accounts_inner: reloading LLM config
2026-10-02 22:20:18,425 WARNING core: LLM config load failed: cannot schedule new futures after shutdown
2026-10-02 22:20:18,426 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-10-02 22:20:22,829 INFO core: Event loop thread started, running loop forever
2026-10-02 22:20:23,130 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 22:20:23,134 INFO core: _init_accounts coroutine started
2026-10-02 22:20:23,136 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 22:20:23,141 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 22:25:12,022 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-02 22:25:12,022 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-02 22:25:12,024 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-02 22:25:12,026 INFO core: _init_accounts_inner: reloading LLM config
2026-10-02 22:25:12,029 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 22:30:34,135 INFO core: Event loop thread started, running loop forever
2026-10-02 22:30:34,436 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 22:30:34,441 INFO core: _init_accounts coroutine started
2026-10-02 22:30:34,442 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 22:30:34,452 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 22:35:21,766 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 22:40:50,351 INFO core: Event loop thread started, running loop forever
2026-10-02 22:40:50,652 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 22:40:50,654 INFO core: _init_accounts coroutine started
2026-10-02 22:40:50,656 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 22:40:50,662 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 22:45:36,901 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-02 22:45:36,902 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-02 22:45:36,903 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 22:45:36,903 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-02 22:50:30,112 INFO core: _init_accounts_inner: reloading LLM config
2026-10-02 22:50:30,115 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 22:55:04,808 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 23:00:17,207 INFO core: Event loop thread started, running loop forever
2026-10-02 23:00:17,508 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 23:00:17,511 INFO core: _init_accounts coroutine started
2026-10-02 23:00:17,512 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 23:00:17,519 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 23:05:43,652 INFO core: Event loop thread started, running loop forever
2026-10-02 23:05:43,955 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 23:05:43,960 INFO core: _init_accounts coroutine started
2026-10-02 23:05:43,960 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 23:05:43,966 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 23:10:07,702 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 23:15:17,417 INFO core: Event loop thread started, running loop forever
2026-10-02 23:15:17,718 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 23:15:17,721 INFO core: _init_accounts coroutine started
2026-10-02 23:15:17,722 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 23:15:17,728 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 23:20:05,585 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 23:25:12,360 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-10-02 23:25:37,086 INFO core: Event loop thread started, running loop forever
2026-10-02 23:25:37,387 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 23:25:37,389 INFO core: _init_accounts coroutine started
2026-10-02 23:25:37,391 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 23:25:37,399 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 23:25:37,400 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-02 23:25:37,404 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-02 23:30:13,817 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-02 23:30:13,826 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 23:35:20,388 INFO core: _init_accounts_inner: reloading LLM config
2026-10-02 23:35:27,131 INFO core: Event loop thread started, running loop forever
2026-10-02 23:35:27,432 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 23:35:27,435 INFO core: _init_accounts coroutine started
2026-10-02 23:35:27,436 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 23:35:27,441 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 23:40:16,764 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 23:45:45,184 INFO core: Event loop thread started, running loop forever
2026-10-02 23:45:45,485 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 23:45:45,488 INFO core: _init_accounts coroutine started
2026-10-02 23:45:45,490 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 23:45:45,495 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 23:50:17,511 INFO core: status() clients=0 connected=False forwarding=False
2026-10-02 23:55:44,900 INFO core: Event loop thread started, running loop forever
2026-10-02 23:55:45,201 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-02 23:55:45,209 INFO core: _init_accounts coroutine started
2026-10-02 23:55:45,209 INFO core: _init_accounts_inner: starting DB migrations
2026-10-02 23:55:45,215 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 00:00:16,520 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 00:05:23,029 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-03 00:05:23,029 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-03 00:05:23,515 INFO core: Event loop thread started, running loop forever
2026-10-03 00:05:23,816 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-03 00:05:23,819 INFO core: _init_accounts coroutine started
2026-10-03 00:05:23,820 INFO core: _init_accounts_inner: starting DB migrations
2026-10-03 00:05:23,827 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 00:10:30,360 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-10-03 00:10:43,692 INFO core: Event loop thread started, running loop forever
2026-10-03 00:10:43,993 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-03 00:10:43,997 INFO core: _init_accounts coroutine started
2026-10-03 00:10:43,999 INFO core: _init_accounts_inner: starting DB migrations
2026-10-03 00:10:44,005 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-03 00:10:44,005 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-03 00:10:44,007 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 00:15:05,355 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-03 00:15:05,355 WARNING core: ensure_pair_schema failed: cannot schedule new futures after shutdown
2026-10-03 00:15:05,356 INFO core: _init_accounts_inner: reloading LLM config
2026-10-03 00:15:05,356 WARNING core: LLM config load failed: cannot schedule new futures after shutdown
2026-10-03 00:15:05,356 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-10-03 00:15:53,377 INFO core: Event loop thread started, running loop forever
2026-10-03 00:15:53,679 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-03 00:15:53,682 INFO core: _init_accounts coroutine started
2026-10-03 00:15:53,683 INFO core: _init_accounts_inner: starting DB migrations
2026-10-03 00:15:53,692 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 00:20:15,505 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-03 00:20:15,505 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-03 00:20:15,508 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 00:25:06,210 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 00:30:13,380 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-03 00:30:28,913 INFO core: Event loop thread started, running loop forever
2026-10-03 00:30:29,213 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-03 00:30:29,217 INFO core: _init_accounts coroutine started
2026-10-03 00:30:29,219 INFO core: _init_accounts_inner: starting DB migrations
2026-10-03 00:30:29,226 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 00:35:51,239 INFO core: Event loop thread started, running loop forever
2026-10-03 00:35:51,540 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-03 00:35:51,546 INFO core: _init_accounts coroutine started
2026-10-03 00:35:51,546 INFO core: _init_accounts_inner: starting DB migrations
2026-10-03 00:35:51,559 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 00:40:48,389 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-03 00:40:48,390 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-03 00:40:48,395 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 00:45:48,601 INFO core: Event loop thread started, running loop forever
2026-10-03 00:45:48,902 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-03 00:45:48,909 INFO core: _init_accounts coroutine started
2026-10-03 00:45:48,909 INFO core: _init_accounts_inner: starting DB migrations
2026-10-03 00:45:48,912 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 00:50:36,211 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-03 00:50:36,212 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-03 00:50:36,213 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 00:55:52,919 INFO core: Event loop thread started, running loop forever
2026-10-03 00:55:53,221 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-03 00:55:53,224 INFO core: _init_accounts coroutine started
2026-10-03 00:55:53,225 INFO core: _init_accounts_inner: starting DB migrations
2026-10-03 00:55:53,233 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 01:00:39,787 INFO core: Event loop thread started, running loop forever
2026-10-03 01:00:40,088 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-03 01:00:40,093 INFO core: _init_accounts coroutine started
2026-10-03 01:00:40,094 INFO core: _init_accounts_inner: starting DB migrations
2026-10-03 01:00:40,101 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 01:05:23,493 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 01:10:44,773 INFO core: Event loop thread started, running loop forever
2026-10-03 01:10:45,074 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-03 01:10:45,077 INFO core: _init_accounts coroutine started
2026-10-03 01:10:45,079 INFO core: _init_accounts_inner: starting DB migrations
2026-10-03 01:10:45,084 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 01:15:31,795 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 01:20:37,297 INFO core: Event loop thread started, running loop forever
2026-10-03 01:20:37,598 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-03 01:20:37,602 INFO core: _init_accounts coroutine started
2026-10-03 01:20:37,605 INFO core: _init_accounts_inner: starting DB migrations
2026-10-03 01:20:37,612 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 01:25:15,162 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-10-03 01:25:15,184 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 01:30:13,787 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 01:35:38,325 INFO core: Event loop thread started, running loop forever
2026-10-03 01:35:38,627 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-03 01:35:38,636 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 01:35:38,637 INFO core: _init_accounts coroutine started
2026-10-03 01:35:38,638 INFO core: _init_accounts_inner: starting DB migrations
2026-10-03 01:40:35,497 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 01:45:32,127 INFO core: Event loop thread started, running loop forever
2026-10-03 01:45:32,428 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-03 01:45:32,432 INFO core: _init_accounts coroutine started
2026-10-03 01:45:32,434 INFO core: _init_accounts_inner: starting DB migrations
2026-10-03 01:45:32,442 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 01:45:41,141 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-10-03 01:50:43,025 INFO core: Event loop thread started, running loop forever
2026-10-03 01:50:43,326 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-03 01:50:43,330 INFO core: _init_accounts coroutine started
2026-10-03 01:50:43,331 INFO core: _init_accounts_inner: starting DB migrations
2026-10-03 01:50:43,337 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 01:55:05,281 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-10-03 01:55:05,294 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 02:00:15,069 INFO core: Event loop thread started, running loop forever
2026-10-03 02:00:15,370 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-03 02:00:15,376 INFO core: _init_accounts coroutine started
2026-10-03 02:00:15,377 INFO core: _init_accounts_inner: starting DB migrations
2026-10-03 02:00:15,385 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 02:05:18,096 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-03 02:05:18,097 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-03 02:05:18,097 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 02:10:48,002 INFO core: Event loop thread started, running loop forever
2026-10-03 02:10:48,303 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-03 02:10:48,309 INFO core: _init_accounts coroutine started
2026-10-03 02:10:48,310 INFO core: _init_accounts_inner: starting DB migrations
2026-10-03 02:10:48,317 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 02:15:04,539 INFO core: Event loop thread started, running loop forever
2026-10-03 02:15:04,840 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-03 02:15:04,847 INFO core: _init_accounts coroutine started
2026-10-03 02:15:04,847 INFO core: _init_accounts_inner: starting DB migrations
2026-10-03 02:15:04,861 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 02:20:30,595 INFO core: Event loop thread started, running loop forever
2026-10-03 02:20:30,896 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-03 02:20:30,901 INFO core: _init_accounts coroutine started
2026-10-03 02:20:30,903 INFO core: _init_accounts_inner: starting DB migrations
2026-10-03 02:20:30,909 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 02:25:27,841 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 02:25:27,842 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-03 02:25:27,842 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-03 02:30:42,482 INFO core: Event loop thread started, running loop forever
2026-10-03 02:30:42,783 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-03 02:30:42,787 INFO core: _init_accounts coroutine started
2026-10-03 02:30:42,788 INFO core: _init_accounts_inner: starting DB migrations
2026-10-03 02:30:42,792 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 02:35:50,970 INFO core: Event loop thread started, running loop forever
2026-10-03 02:35:51,272 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-03 02:35:51,275 INFO core: _init_accounts coroutine started
2026-10-03 02:35:51,276 INFO core: _init_accounts_inner: starting DB migrations
2026-10-03 02:35:51,283 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 02:40:13,716 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-03 02:40:13,719 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-03 02:40:13,720 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 02:45:20,352 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-03 02:45:20,352 WARNING core: ensure_pair_schema failed: cannot schedule new futures after shutdown
2026-10-03 02:45:20,353 INFO core: _init_accounts_inner: reloading LLM config
2026-10-03 02:45:20,353 WARNING core: LLM config load failed: cannot schedule new futures after shutdown
2026-10-03 02:45:20,353 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-10-03 02:45:22,405 INFO core: Event loop thread started, running loop forever
2026-10-03 02:45:22,709 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-03 02:45:22,712 INFO core: _init_accounts coroutine started
2026-10-03 02:45:22,715 INFO core: _init_accounts_inner: starting DB migrations
2026-10-03 02:45:22,721 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 02:50:34,708 INFO core: Event loop thread started, running loop forever
2026-10-03 02:50:35,009 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-03 02:50:35,015 INFO core: _init_accounts coroutine started
2026-10-03 02:50:35,015 INFO core: _init_accounts_inner: starting DB migrations
2026-10-03 02:50:35,021 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 02:55:48,613 INFO core: Event loop thread started, running loop forever
2026-10-03 02:55:48,914 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-03 02:55:48,919 INFO core: _init_accounts coroutine started
2026-10-03 02:55:48,919 INFO core: _init_accounts_inner: starting DB migrations
2026-10-03 02:55:48,925 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 03:00:20,434 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 03:05:25,770 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-03 03:05:25,770 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-03 03:05:25,773 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-03 03:05:25,775 INFO core: _init_accounts_inner: reloading LLM config
2026-10-03 03:05:25,791 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 03:10:31,409 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-10-03 03:10:31,410 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-10-03 03:10:31,410 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 180, in _init_accounts_inner
    await self._start_account_client(acct["id"])
  File "/home/wovewbge/quill.nx.kg/core.py", line 236, in _start_account_client
    session_str = await self._run_db(self.db.get_account_session, account_id)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-10-03 03:10:39,915 INFO core: Event loop thread started, running loop forever
2026-10-03 03:10:40,216 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-03 03:10:40,220 INFO core: _init_accounts coroutine started
2026-10-03 03:10:40,220 INFO core: _init_accounts_inner: starting DB migrations
2026-10-03 03:10:40,233 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 03:15:37,032 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-03 03:15:37,033 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 03:15:37,033 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-03 03:15:37,035 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-03 03:15:37,036 INFO core: _init_accounts_inner: reloading LLM config
2026-10-03 03:20:40,602 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 03:25:20,739 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-10-03 03:25:20,740 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-10-03 03:25:20,740 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 03:30:04,167 INFO core: Account 2: connecting to Telegram via 91.108.56.178...
2026-10-03 03:30:04,172 INFO telethon.network.mtprotosender: Connecting to 91.108.56.178:443/TcpAbridged...
2026-10-03 03:30:04,182 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 03:35:18,973 INFO core: Event loop thread started, running loop forever
2026-10-03 03:35:19,274 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-03 03:35:19,283 INFO core: _init_accounts coroutine started
2026-10-03 03:35:19,283 INFO core: _init_accounts_inner: starting DB migrations
2026-10-03 03:35:19,289 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 03:40:25,435 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-10-03 03:40:33,320 INFO core: Event loop thread started, running loop forever
2026-10-03 03:40:33,621 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-03 03:40:33,626 INFO core: _init_accounts coroutine started
2026-10-03 03:40:33,627 INFO core: _init_accounts_inner: starting DB migrations
2026-10-03 03:40:33,633 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 03:45:50,342 INFO core: Event loop thread started, running loop forever
2026-10-03 03:45:50,643 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-03 03:45:50,651 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 03:50:36,726 INFO core: _init_accounts coroutine started
2026-10-03 03:50:36,728 INFO core: _init_accounts_inner: starting DB migrations
2026-10-03 03:50:36,733 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 03:55:21,716 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-10-03 03:55:21,726 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 04:00:07,508 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 04:05:25,753 INFO core: Event loop thread started, running loop forever
2026-10-03 04:05:26,055 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-03 04:05:26,061 INFO core: _init_accounts coroutine started
2026-10-03 04:05:26,062 INFO core: _init_accounts_inner: starting DB migrations
2026-10-03 04:05:26,073 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 04:10:27,247 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 04:15:34,418 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-03 04:15:40,232 INFO core: Event loop thread started, running loop forever
2026-10-03 04:15:40,533 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-03 04:15:40,539 INFO core: _init_accounts coroutine started
2026-10-03 04:15:40,540 INFO core: _init_accounts_inner: starting DB migrations
2026-10-03 04:15:40,545 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 04:20:19,653 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-03 04:20:19,653 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-03 04:20:19,658 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-03 04:20:19,663 INFO core: _init_accounts_inner: reloading LLM config
2026-10-03 04:20:19,667 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 04:25:20,524 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 04:30:27,357 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-10-03 04:30:27,357 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-10-03 04:30:27,357 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 180, in _init_accounts_inner
    await self._start_account_client(acct["id"])
  File "/home/wovewbge/quill.nx.kg/core.py", line 236, in _start_account_client
    session_str = await self._run_db(self.db.get_account_session, account_id)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-10-03 04:30:35,860 INFO core: Event loop thread started, running loop forever
2026-10-03 04:30:36,161 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-03 04:30:36,165 INFO core: _init_accounts coroutine started
2026-10-03 04:30:36,166 INFO core: _init_accounts_inner: starting DB migrations
2026-10-03 04:30:36,174 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 04:35:43,561 INFO core: Event loop thread started, running loop forever
2026-10-03 04:35:43,862 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-03 04:35:43,865 INFO core: _init_accounts coroutine started
2026-10-03 04:35:43,867 INFO core: _init_accounts_inner: starting DB migrations
2026-10-03 04:35:43,874 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 04:40:09,019 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 04:45:03,374 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-03 04:45:03,378 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-03 04:45:03,421 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-03 04:45:03,421 WARNING core: ensure_pair_schema failed: cannot schedule new futures after shutdown
2026-10-03 04:45:03,422 INFO core: _init_accounts_inner: reloading LLM config
2026-10-03 04:45:03,422 WARNING core: LLM config load failed: cannot schedule new futures after shutdown
2026-10-03 04:45:03,422 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-10-03 04:45:03,423 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 180, in _init_accounts_inner
    await self._start_account_client(acct["id"])
  File "/home/wovewbge/quill.nx.kg/core.py", line 236, in _start_account_client
    session_str = await self._run_db(self.db.get_account_session, account_id)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-10-03 04:45:35,935 INFO core: Event loop thread started, running loop forever
2026-10-03 04:45:36,236 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-03 04:45:36,240 INFO core: _init_accounts coroutine started
2026-10-03 04:45:36,241 INFO core: _init_accounts_inner: starting DB migrations
2026-10-03 04:45:36,245 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 04:50:05,246 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-03 04:50:05,247 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-03 04:50:05,250 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-03 04:50:05,252 INFO core: _init_accounts_inner: reloading LLM config
2026-10-03 04:50:05,256 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 04:55:07,823 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 05:00:07,169 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 05:05:16,696 INFO core: Event loop thread started, running loop forever
2026-10-03 05:05:16,997 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-03 05:05:17,001 INFO core: _init_accounts coroutine started
2026-10-03 05:05:17,002 INFO core: _init_accounts_inner: starting DB migrations
2026-10-03 05:05:17,010 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 05:10:03,860 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 05:15:10,395 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-03 05:15:10,396 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-03 05:15:10,396 WARNING core: ensure_llm_schema failed: cannot schedule new futures after shutdown
2026-10-03 05:15:10,397 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-03 05:15:10,397 WARNING core: ensure_pair_schema failed: cannot schedule new futures after shutdown
2026-10-03 05:15:10,397 INFO core: _init_accounts_inner: reloading LLM config
2026-10-03 05:15:10,397 WARNING core: LLM config load failed: cannot schedule new futures after shutdown
2026-10-03 05:15:10,397 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-10-03 05:15:45,000 INFO core: Event loop thread started, running loop forever
2026-10-03 05:15:45,301 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-03 05:15:45,305 INFO core: _init_accounts coroutine started
2026-10-03 05:15:45,306 INFO core: _init_accounts_inner: starting DB migrations
2026-10-03 05:15:45,316 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 05:20:04,792 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-10-03 05:20:04,807 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 05:25:17,056 INFO core: Event loop thread started, running loop forever
2026-10-03 05:25:17,357 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-03 05:25:17,365 INFO core: _init_accounts coroutine started
2026-10-03 05:25:17,365 INFO core: _init_accounts_inner: starting DB migrations
2026-10-03 05:25:17,367 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 05:30:52,177 INFO core: Event loop thread started, running loop forever
2026-10-03 05:30:52,481 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-03 05:30:52,489 INFO core: _init_accounts coroutine started
2026-10-03 05:30:52,490 INFO core: _init_accounts_inner: starting DB migrations
2026-10-03 05:30:52,493 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 05:35:37,285 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-03 05:35:37,286 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 05:35:37,287 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-03 05:40:09,127 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-03 05:40:09,132 INFO core: _init_accounts_inner: reloading LLM config
2026-10-03 05:40:09,144 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 05:45:16,402 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-10-03 05:45:47,416 INFO core: Event loop thread started, running loop forever
2026-10-03 05:45:47,717 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-03 05:45:47,721 INFO core: _init_accounts coroutine started
2026-10-03 05:45:47,724 INFO core: _init_accounts_inner: starting DB migrations
2026-10-03 05:45:47,734 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 05:50:05,860 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-03 05:50:05,861 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-03 05:50:05,892 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-03 05:50:05,895 INFO core: _init_accounts_inner: reloading LLM config
2026-10-03 05:50:05,920 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-10-03 05:50:05,921 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-10-03 05:50:05,936 INFO core: Account 2: connecting to Telegram via 91.108.56.178...
2026-10-03 05:50:05,937 INFO telethon.network.mtprotosender: Connecting to 91.108.56.178:443/TcpAbridged...
2026-10-03 05:50:05,941 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 05:55:11,420 WARNING telethon.network.mtprotosender: Attempt 1 at connecting failed: TimeoutError: 
2026-10-03 05:55:11,422 WARNING core: Account 2: connect timed out after 35s
2026-10-03 05:55:11,423 INFO telethon.network.mtprotosender: Disconnecting from 91.108.56.178:443/TcpAbridged...
2026-10-03 05:55:51,723 INFO core: Event loop thread started, running loop forever
2026-10-03 05:55:52,026 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-03 05:55:52,054 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 06:00:25,231 INFO core: _init_accounts coroutine started
2026-10-03 06:00:25,233 INFO core: _init_accounts_inner: starting DB migrations
2026-10-03 06:00:25,239 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 06:05:50,084 INFO core: Event loop thread started, running loop forever
2026-10-03 06:05:50,389 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-03 06:05:50,395 INFO core: _init_accounts coroutine started
2026-10-03 06:05:50,396 INFO core: _init_accounts_inner: starting DB migrations
2026-10-03 06:05:50,408 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 06:10:38,454 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 06:15:25,110 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-03 06:15:25,112 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-03 06:15:25,116 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 06:20:37,468 INFO core: Event loop thread started, running loop forever
2026-10-03 06:20:37,770 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-03 06:20:37,773 INFO core: _init_accounts coroutine started
2026-10-03 06:20:37,776 INFO core: _init_accounts_inner: starting DB migrations
2026-10-03 06:20:37,791 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 06:25:11,493 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 06:30:35,164 INFO core: Event loop thread started, running loop forever
2026-10-03 06:30:35,468 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-03 06:30:35,473 INFO core: _init_accounts coroutine started
2026-10-03 06:30:35,475 INFO core: _init_accounts_inner: starting DB migrations
2026-10-03 06:30:35,496 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 06:35:39,848 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 06:40:32,832 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-03 06:40:32,833 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-03 06:40:32,837 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-03 06:40:32,838 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 06:45:23,220 INFO core: _init_accounts_inner: reloading LLM config
2026-10-03 06:45:23,230 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 06:50:11,161 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 06:55:10,233 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 06:55:10,235 INFO core: LLM engine: {'enabled': False, 'provider': 'openai-compatible', 'model': 'zai-glm-4.7', 'base_url': 'https://api.cerebras.ai/v1', 'api_key_set': True, 'client_available': True, 'available': False, 'min_confidence': 0.8, 'webhook_url_set': False, 'timeout': 12.0, 'max_tokens': 512}
2026-10-03 07:00:02,388 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-10-03 07:00:54,111 INFO core: Event loop thread started, running loop forever
2026-10-03 07:00:54,413 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-03 07:00:54,418 INFO core: _init_accounts coroutine started
2026-10-03 07:00:54,419 INFO core: _init_accounts_inner: starting DB migrations
2026-10-03 07:00:54,423 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 07:05:06,145 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 07:10:13,402 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-03 07:10:13,403 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-03 07:10:13,403 WARNING core: ensure_llm_schema failed: cannot schedule new futures after shutdown
2026-10-03 07:10:13,404 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-03 07:10:13,404 WARNING core: ensure_pair_schema failed: cannot schedule new futures after shutdown
2026-10-03 07:10:13,404 INFO core: _init_accounts_inner: reloading LLM config
2026-10-03 07:10:13,404 WARNING core: LLM config load failed: cannot schedule new futures after shutdown
2026-10-03 07:10:13,404 INFO core: _init_accounts_inner: schema/LLM steps complete
2026-10-03 07:10:13,404 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 180, in _init_accounts_inner
    await self._start_account_client(acct["id"])
  File "/home/wovewbge/quill.nx.kg/core.py", line 236, in _start_account_client
    session_str = await self._run_db(self.db.get_account_session, account_id)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-10-03 07:10:34,495 INFO core: Event loop thread started, running loop forever
2026-10-03 07:10:34,797 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-03 07:10:34,801 INFO core: _init_accounts coroutine started
2026-10-03 07:10:34,802 INFO core: _init_accounts_inner: starting DB migrations
2026-10-03 07:10:34,808 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 07:15:12,779 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 07:20:18,472 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 149, in _init_accounts_inner
    await self._run_db(self.db.migrate_legacy_session)
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-10-03 07:20:41,931 INFO core: Event loop thread started, running loop forever
2026-10-03 07:20:42,232 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-03 07:20:42,236 INFO core: _init_accounts coroutine started
2026-10-03 07:20:42,238 INFO core: _init_accounts_inner: starting DB migrations
2026-10-03 07:20:42,248 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 07:25:35,683 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 07:25:35,684 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-10-03 07:30:35,586 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 07:35:39,747 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 07:40:49,834 INFO core: Event loop thread started, running loop forever
2026-10-03 07:40:50,135 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-03 07:40:50,140 INFO core: _init_accounts coroutine started
2026-10-03 07:40:50,142 INFO core: _init_accounts_inner: starting DB migrations
2026-10-03 07:40:50,150 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 07:45:39,494 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-03 07:45:39,496 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-03 07:45:39,497 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-03 07:45:39,499 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 07:45:39,500 INFO core: _init_accounts_inner: reloading LLM config
2026-10-03 07:50:53,732 INFO core: Event loop thread started, running loop forever
2026-10-03 07:50:54,034 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-03 07:50:54,039 INFO core: _init_accounts coroutine started
2026-10-03 07:50:54,039 INFO core: _init_accounts_inner: starting DB migrations
2026-10-03 07:50:54,047 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 07:55:25,168 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-03 07:55:25,168 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-03 07:55:25,201 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-03 07:55:25,209 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 08:00:40,148 INFO core: Event loop thread started, running loop forever
2026-10-03 08:00:40,449 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-03 08:00:40,456 INFO core: _init_accounts coroutine started
2026-10-03 08:00:40,456 INFO core: _init_accounts_inner: starting DB migrations
2026-10-03 08:00:40,461 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 08:05:49,969 INFO core: Event loop thread started, running loop forever
2026-10-03 08:05:50,270 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-03 08:05:50,275 INFO core: _init_accounts coroutine started
2026-10-03 08:05:50,276 INFO core: _init_accounts_inner: starting DB migrations
2026-10-03 08:05:50,291 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 08:10:06,121 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-03 08:10:06,121 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-03 08:10:06,124 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-03 08:10:06,126 INFO core: _init_accounts_inner: reloading LLM config
2026-10-03 08:10:06,130 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 08:15:37,967 INFO core: Event loop thread started, running loop forever
2026-10-03 08:15:38,268 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-03 08:15:38,283 INFO core: _init_accounts coroutine started
2026-10-03 08:15:38,283 INFO core: _init_accounts_inner: starting DB migrations
2026-10-03 08:15:38,284 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 08:20:09,514 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 08:25:15,251 INFO core: Event loop thread started, running loop forever
2026-10-03 08:25:15,552 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-03 08:25:15,556 INFO core: _init_accounts coroutine started
2026-10-03 08:25:15,558 INFO core: _init_accounts_inner: starting DB migrations
2026-10-03 08:25:15,568 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 08:30:08,332 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-10-03 08:30:08,363 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 08:35:26,713 INFO core: Event loop thread started, running loop forever
2026-10-03 08:35:27,014 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-03 08:35:27,039 INFO core: _init_accounts coroutine started
2026-10-03 08:35:27,039 INFO core: _init_accounts_inner: starting DB migrations
2026-10-03 08:35:27,040 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 08:40:43,434 INFO core: Event loop thread started, running loop forever
2026-10-03 08:40:43,735 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-03 08:40:43,745 INFO core: _init_accounts coroutine started
2026-10-03 08:40:43,746 INFO core: _init_accounts_inner: starting DB migrations
2026-10-03 08:40:43,751 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 08:45:42,946 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 08:50:21,957 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-03 08:50:21,958 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-03 08:50:21,960 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 08:55:17,229 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-03 08:55:17,238 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 09:00:22,147 INFO core: _init_accounts_inner: reloading LLM config
2026-10-03 09:00:22,155 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 09:05:40,046 INFO core: Event loop thread started, running loop forever
2026-10-03 09:05:40,347 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-03 09:05:40,360 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 09:10:33,422 INFO core: _init_accounts coroutine started
2026-10-03 09:10:33,423 INFO core: _init_accounts_inner: starting DB migrations
2026-10-03 09:10:33,432 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 09:15:03,430 ERROR core: _init_accounts failed: cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/asyncio/base_events.py", line 902, in run_in_executor
    executor.submit(func, *args), loop=self)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 171, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
2026-10-03 09:15:27,475 INFO core: Event loop thread started, running loop forever
2026-10-03 09:15:27,786 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-03 09:15:27,793 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 09:20:13,467 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 09:25:14,507 INFO core: _init_accounts coroutine started
2026-10-03 09:25:14,511 INFO core: _init_accounts_inner: starting DB migrations
2026-10-03 09:25:14,517 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 09:30:10,880 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 09:35:16,401 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-03 09:35:16,401 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-03 09:35:16,402 WARNING core: ensure_llm_schema failed: cannot schedule new futures after shutdown
2026-10-03 09:35:16,403 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-03 09:35:16,404 WARNING core: ensure_pair_schema failed: cannot schedule new futures after shutdown
2026-10-03 09:35:16,404 INFO core: _init_accounts_inner: reloading LLM config
2026-10-03 09:35:42,508 INFO core: Event loop thread started, running loop forever
2026-10-03 09:35:42,816 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-03 09:35:42,821 INFO core: _init_accounts coroutine started
2026-10-03 09:35:42,822 INFO core: _init_accounts_inner: starting DB migrations
2026-10-03 09:35:42,828 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 09:40:13,854 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 09:45:28,783 INFO core: Event loop thread started, running loop forever
2026-10-03 09:45:29,085 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-03 09:45:29,089 INFO core: _init_accounts coroutine started
2026-10-03 09:45:29,091 INFO core: _init_accounts_inner: starting DB migrations
2026-10-03 09:45:29,098 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 09:50:18,894 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 09:55:16,888 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 10:00:23,422 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-03 10:00:23,422 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-03 10:00:23,429 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-03 10:00:39,945 INFO core: Event loop thread started, running loop forever
2026-10-03 10:00:40,246 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-03 10:00:40,249 INFO core: _init_accounts coroutine started
2026-10-03 10:00:40,250 INFO core: _init_accounts_inner: starting DB migrations
2026-10-03 10:00:40,260 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 10:05:23,163 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-03 10:05:23,164 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-03 10:05:23,166 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-03 10:05:23,169 INFO core: _init_accounts_inner: reloading LLM config
2026-10-03 10:05:23,170 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 10:10:50,836 INFO core: Event loop thread started, running loop forever
2026-10-03 10:10:51,137 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-03 10:10:51,142 INFO core: _init_accounts coroutine started
2026-10-03 10:10:51,142 INFO core: _init_accounts_inner: starting DB migrations
2026-10-03 10:10:51,148 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 10:15:52,140 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 10:20:36,345 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-03 10:20:36,345 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-03 10:20:36,348 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 10:25:36,336 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-03 10:25:36,339 INFO core: _init_accounts_inner: reloading LLM config
2026-10-03 10:25:36,353 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 10:30:47,156 INFO core: Event loop thread started, running loop forever
2026-10-03 10:30:47,457 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-03 10:30:47,461 INFO core: _init_accounts coroutine started
2026-10-03 10:30:47,463 INFO core: _init_accounts_inner: starting DB migrations
2026-10-03 10:30:47,468 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 10:33:56,368 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 10:35:10,139 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 10:40:32,352 INFO core: Event loop thread started, running loop forever
2026-10-03 10:40:32,653 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-03 10:40:32,656 INFO core: _init_accounts coroutine started
2026-10-03 10:40:32,658 INFO core: _init_accounts_inner: starting DB migrations
2026-10-03 10:40:32,664 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 10:45:10,484 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 10:50:48,303 INFO core: Event loop thread started, running loop forever
2026-10-03 10:50:48,604 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-03 10:50:48,610 INFO core: _init_accounts coroutine started
2026-10-03 10:50:48,611 INFO core: _init_accounts_inner: starting DB migrations
2026-10-03 10:50:48,617 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 10:55:10,591 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 11:00:16,384 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-03 11:00:40,502 INFO core: Event loop thread started, running loop forever
2026-10-03 11:00:40,805 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-03 11:00:40,810 INFO core: _init_accounts coroutine started
2026-10-03 11:00:40,811 INFO core: _init_accounts_inner: starting DB migrations
2026-10-03 11:00:40,816 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 11:05:20,507 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 11:10:35,843 INFO core: Event loop thread started, running loop forever
2026-10-03 11:10:36,145 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-03 11:10:36,148 INFO core: _init_accounts coroutine started
2026-10-03 11:10:36,150 INFO core: _init_accounts_inner: starting DB migrations
2026-10-03 11:10:36,155 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 11:15:25,000 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 141, in _init_accounts_inner
    self._lock_conn = await self._run_db(self.db.acquire_core_lock)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 87, in acquire_core_lock
    conn = _create_connection()
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-10-03 11:15:25,008 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 11:20:54,120 INFO core: Event loop thread started, running loop forever
2026-10-03 11:20:54,421 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-03 11:20:54,425 INFO core: _init_accounts coroutine started
2026-10-03 11:20:54,425 INFO core: _init_accounts_inner: starting DB migrations
2026-10-03 11:20:54,437 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 11:20:54,444 INFO core: _init_accounts_inner: migrate_legacy_session done
2026-10-03 11:20:54,444 INFO core: _init_accounts_inner: running ensure_llm_schema
2026-10-03 11:25:11,843 INFO core: _init_accounts_inner: running ensure_pair_schema
2026-10-03 11:25:11,846 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 11:30:16,815 INFO core: Event loop thread started, running loop forever
2026-10-03 11:30:17,117 INFO core: Scheduling _init_accounts on event loop (alive=True)
2026-10-03 11:30:17,120 INFO core: _init_accounts coroutine started
2026-10-03 11:30:17,121 INFO core: _init_accounts_inner: starting DB migrations
2026-10-03 11:30:17,124 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 11:31:48,689 ERROR core: _init_accounts failed: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
Traceback (most recent call last):
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 834, in _write_bytes
    self._sock.sendall(data)
    ~~~~~~~~~~~~~~~~~~^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wovewbge/quill.nx.kg/core.py", line 114, in _init_accounts
    await self._init_accounts_inner()
  File "/home/wovewbge/quill.nx.kg/core.py", line 126, in _init_accounts_inner
    accounts = await self._run_db(self.db.get_accounts)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wovewbge/quill.nx.kg/core.py", line 96, in _run_db
    return await self.loop.run_in_executor(self._executor, func, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/alt/python313/lib64/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/wovewbge/quill.nx.kg/db.py", line 540, in get_accounts
    with self._conn() as conn:
         ~~~~~~~~~~^^
  File "/opt/alt/python313/lib64/python3.13/contextlib.py", line 141, in __enter__
    return next(self.gen)
  File "/home/wovewbge/quill.nx.kg/db.py", line 59, in _conn
    conn = _pool.connect()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 448, in connect
    return _ConnectionFairy._checkout(self)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 1272, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 712, in checkout
    rec = pool._do_get()
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/impl.py", line 178, in _do_get
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/impl.py", line 176, in _do_get
    return self._create_connection()
           ~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 389, in _create_connection
    return _ConnectionRecord(self)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 674, in __init__
    self.__connect()
    ~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 900, in __connect
    with util.safe_reraise():
         ~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 122, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 896, in __connect
    self.dbapi_connection = connection = pool._invoke_creator(self)
                                         ~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib64/python3.13/site-packages/sqlalchemy/pool/base.py", line 361, in <lambda>
    return lambda rec: creator_fn()
                       ~~~~~~~~~~^^
  File "/home/wovewbge/quill.nx.kg/db.py", line 15, in _create_connection
    return pymysql.connect(
           ~~~~~~~~~~~~~~~^
        host=config.MYSQL_HOST,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<13 lines>...
        connect_timeout=5,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 372, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 702, in connect
    self._request_authentication()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 999, in _request_authentication
    self.write_packet(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 760, in write_packet
    self._write_bytes(data)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/wovewbge/virtualenv/quill.nx.kg/3.13/lib/python3.13/site-packages/pymysql/connections.py", line 837, in _write_bytes
    raise err.OperationalError(
        CR.CR_SERVER_GONE_ERROR, f"MySQL server has gone away ({e!r})"
    )
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")
2026-10-03 11:31:48,699 INFO core: status() clients=0 connected=False forwarding=False
2026-10-03 11:35:19,508 INFO core: status() clients=0 connected=False forwarding=False
