MySQLDb 使用弱代理来防止游标和连接之间的循环依赖。
但是您会从关于 weakref 的文档中期望您仍然可以测试等效性。然而:
In [36]: interactive.cursor.connection.thread_id()
Out[36]: 4267758
In [37]: interactive.web_logic.conns.primary.thread_id()
Out[37]: 4267758
In [38]: interactive.cursor.connection == interactive.web_logic.conns.primary
Out[38]: False
In [39]: interactive.cursor.connection
Out[39]: <weakproxy at 0x3881c60 to Connection at 0x94c010>
In [40]: interactive.web_logic.conns.primary
Out[40]: <_mysql.connection open to 'xendb01' at 94c010>
如何判断连接是否相同?