mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-24 22:00:22 -07:00
Fix wait_for with newer versions of psutil. (#26455)
* Add support for newer psutil versions. * Fix psutil install in wait_for integration test. * Fix test requirements for wait_for elapsed.
This commit is contained in:
parent
2a041d10d2
commit
895e6c5d06
2 changed files with 23 additions and 16 deletions
|
@ -243,14 +243,23 @@ class TCPConnectionInfo(object):
|
|||
def get_active_connections_count(self):
|
||||
active_connections = 0
|
||||
for p in psutil.process_iter():
|
||||
connections = p.get_connections(kind='inet')
|
||||
if hasattr(p, 'get_connections'):
|
||||
connections = p.get_connections(kind='inet')
|
||||
else:
|
||||
connections = p.connections(kind='inet')
|
||||
for conn in connections:
|
||||
if conn.status not in self.module.params['active_connection_states']:
|
||||
continue
|
||||
(local_ip, local_port) = conn.local_address
|
||||
if hasattr(conn, 'local_address'):
|
||||
(local_ip, local_port) = conn.local_address
|
||||
else:
|
||||
(local_ip, local_port) = conn.laddr
|
||||
if self.port != local_port:
|
||||
continue
|
||||
(remote_ip, remote_port) = conn.remote_address
|
||||
if hasattr(conn, 'remote_address'):
|
||||
(remote_ip, remote_port) = conn.remote_address
|
||||
else:
|
||||
(remote_ip, remote_port) = conn.raddr
|
||||
if (conn.family, remote_ip) in self.exclude_ips:
|
||||
continue
|
||||
if any((
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue