In previous code of SSHPool.get(), we pasted the code
from Pool.get() and check if a connection is active before return
it.
However, it's much simpler and cleaner to just call the Pool.get()
and then check the connection before return. With this,we can free
ourselves from manually keeping up with code of Pool.get() in
upstream package eventlet
As a side effect,this patch fixed bug #
1194393 which caused by a
previous bug in eventlet codes before revision 1072
fixed bug #
1194393
Change-Id: Ic2bf2fa1ad82cf8669b6c491c955dcab39eb1510
before returning it. For dead connections create and return a new
connection.
"""
- if self.free_items:
- conn = self.free_items.popleft()
- if conn:
- if conn.get_transport().is_active():
- return conn
- else:
- conn.close()
- return self.create()
- if self.current_size < self.max_size:
- created = self.create()
- self.current_size += 1
- return created
- return self.channel.get()
+ conn = super(SSHPool, self).get()
+ if conn:
+ if conn.get_transport().is_active():
+ return conn
+ else:
+ conn.close()
+ return self.create()
def remove(self, ssh):
"""Close an ssh client and remove it from free_items."""