Error: TypeError: '<' not supported between instances of ...
Error code:
def _close(self, conn, close_conn=False):
key = self.conn_key(conn)
if close_conn:
super(PooledDatabase, self)._close(conn)
elif key in self._in_use:
pool_conn = self._in_use.pop(key)
if self._stale_timeout and self._is_stale(pool_conn.timestamp):
logger.debug('Closing stale connection %s.', key)
super(PooledDatabase, self)._close(conn)
elif self._can_reuse(conn):
logger.debug('Returning %s to pool.', key)
heapq.heappush(self._connections, (pool_conn.timestamp, conn))
else:
logger.debug('Closed %s.', key)
Analysis:When heappush insert heap data, it will first compare the first element (pool_conn.timestamp). If pool_conn.timestamp is the same, it will compare the second element. However, conn does not implement a comparison method.
To fix this problem, you can consider giving up directly when pool_conn.timestamp is the same, without putting it into the connection pool.
for example
if pool_conn.timestamp not in [exist_timestamp for exist_timestamp , _ in self._connections]:
heapq.heappush(self._connections, (pool_conn.timestamp, conn))
Version: 3.17.5 etc.
Error: TypeError: '<' not supported between instances of ...
Error code:
Analysis:When heappush insert heap data, it will first compare the first element (pool_conn.timestamp). If pool_conn.timestamp is the same, it will compare the second element. However, conn does not implement a comparison method. To fix this problem, you can consider giving up directly when pool_conn.timestamp is the same, without putting it into the connection pool.
for example