我想问一下关于python的sqlalchemy库的问题,我在用这个库的异步+连接池管理MySQL,正常来说连接会自动管理的,无需手动的断开连接。问题是:如果我没有手动断开连接,那么终端就会弹出一大堆连接错误的提示,因为连接被自动管理断开了(但这并没有影响程序的功能,程序的目的已经完成了)。
疑惑:我现在可以通过添加“手动的关闭连接”阻止报错的发生,但这样的话就会失去“自动管理连接池”的意义。因为第一次遇见这种问题,所以请教一下大家的建议。
以下是报错提示———— True Exception ignored in: <function Connection.__del__ at 0x0000024CDD01E980> Traceback (most recent call last): File "d:\Uers\创作\Ea\twoxyz\.venv\Lib\site-packages\aiomysql\connection.py", line 1131, in __del__ self.close() File "d:\Uers\创作\Ea\twoxyz\.venv\Lib\site-packages\aiomysql\connection.py", line 339, in close self._writer.transport.close() File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.240.0_x64__qbz5n2kfra8p0\Lib\asyncio\proactor_events.py", line 109, in close self._loop.call_soon(self._call_connection_lost, None) File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.240.0_x64__qbz5n2kfra8p0\Lib\asyncio\base_events.py", line 772, in call_soon self._check_closed() File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.240.0_x64__qbz5n2kfra8p0\Lib\asyncio\base_events.py", line 519, in _check_closed raise RuntimeError('Event loop is closed') RuntimeError: Event loop is closed