There are multiple issues with the connection pool:
- If a
DB instance was not deleted, its connection will never be returned to the pool. And there is no guarantee that __del__ method is to be called soon. Since Redis._borrow_connection does not check for the number of borrowed connections, it is possible for the code to create a lot of connections, that causes an error OSError: all attempts to connect to <redis host> failed
- There can be multiple calls to
__del__ method during garbage collection, adding the same connection to the pool.
For me, it seems that the pool management should be revisited, also I would add an ability to explicitly borrow and return the connection.
There are multiple issues with the connection pool:
DBinstance was not deleted, its connection will never be returned to the pool. And there is no guarantee that__del__method is to be called soon. SinceRedis._borrow_connectiondoes not check for the number of borrowed connections, it is possible for the code to create a lot of connections, that causes an errorOSError: all attempts to connect to <redis host> failed__del__method during garbage collection, adding the same connection to the pool.For me, it seems that the pool management should be revisited, also I would add an ability to explicitly borrow and return the connection.