wait_for - remove an obsolete fallback for Python 2.6 (#63988)
This commit is contained in:
parent
8c8077b5be
commit
39bf09517a
3 changed files with 4 additions and 24 deletions
|
@ -0,0 +1,2 @@
|
|||
bugfixes:
|
||||
- code - removes some Python compatibility code for dealing with socket timeouts in ``wait_for``
|
|
@ -225,7 +225,6 @@ import os
|
|||
import re
|
||||
import select
|
||||
import socket
|
||||
import sys
|
||||
import time
|
||||
import traceback
|
||||
|
||||
|
@ -439,26 +438,6 @@ def _convert_host_to_hex(host):
|
|||
return ips
|
||||
|
||||
|
||||
def _create_connection(host, port, connect_timeout):
|
||||
"""
|
||||
Connect to a 2-tuple (host, port) and return
|
||||
the socket object.
|
||||
|
||||
Args:
|
||||
2-tuple (host, port) and connection timeout
|
||||
Returns:
|
||||
Socket object
|
||||
"""
|
||||
if sys.version_info < (2, 6):
|
||||
(family, _) = (_convert_host_to_ip(host))[0]
|
||||
connect_socket = socket.socket(family, socket.SOCK_STREAM)
|
||||
connect_socket.settimeout(connect_timeout)
|
||||
connect_socket.connect((host, port))
|
||||
else:
|
||||
connect_socket = socket.create_connection((host, port), connect_timeout)
|
||||
return connect_socket
|
||||
|
||||
|
||||
def _timedelta_total_seconds(timedelta):
|
||||
return (
|
||||
timedelta.microseconds + 0.0 +
|
||||
|
@ -548,7 +527,7 @@ def main():
|
|||
break
|
||||
elif port:
|
||||
try:
|
||||
s = _create_connection(host, port, connect_timeout)
|
||||
s = socket.create_connection((host, port), connect_timeout)
|
||||
s.shutdown(socket.SHUT_RDWR)
|
||||
s.close()
|
||||
except Exception:
|
||||
|
@ -598,7 +577,7 @@ def main():
|
|||
elif port:
|
||||
alt_connect_timeout = math.ceil(_timedelta_total_seconds(end - datetime.datetime.utcnow()))
|
||||
try:
|
||||
s = _create_connection(host, port, min(connect_timeout, alt_connect_timeout))
|
||||
s = socket.create_connection((host, port), min(connect_timeout, alt_connect_timeout))
|
||||
except Exception:
|
||||
# Failed to connect by connect_timeout. wait and try again
|
||||
pass
|
||||
|
|
|
@ -5091,7 +5091,6 @@ lib/ansible/modules/utilities/logic/async_status.py use-argspec-type-path
|
|||
lib/ansible/modules/utilities/logic/async_status.py validate-modules!skip
|
||||
lib/ansible/modules/utilities/logic/async_wrapper.py ansible-doc!skip # not an actual module
|
||||
lib/ansible/modules/utilities/logic/async_wrapper.py use-argspec-type-path
|
||||
lib/ansible/modules/utilities/logic/wait_for.py pylint:blacklisted-name
|
||||
lib/ansible/modules/web_infrastructure/ansible_tower/tower_credential.py validate-modules:doc-choices-do-not-match-spec
|
||||
lib/ansible/modules/web_infrastructure/ansible_tower/tower_credential_type.py validate-modules:parameter-type-not-in-doc
|
||||
lib/ansible/modules/web_infrastructure/ansible_tower/tower_credential_type.py validate-modules:doc-missing-type
|
||||
|
|
Loading…
Reference in a new issue