Merge pull request #2401 from larsla/devel
total_seconds not present on timedelta on python2.6
This commit is contained in:
commit
35707bcb3c
1 changed files with 9 additions and 4 deletions
|
@ -322,6 +322,11 @@ def _create_connection( (host, port), connect_timeout):
|
|||
connect_socket = socket.create_connection( (host, port), connect_timeout)
|
||||
return connect_socket
|
||||
|
||||
def _timedelta_total_seconds(timedelta):
|
||||
return (
|
||||
timedelta.microseconds + 0.0 +
|
||||
(timedelta.seconds + timedelta.days * 24 * 3600) * 10 ** 6) / 10 ** 6
|
||||
|
||||
def main():
|
||||
|
||||
module = AnsibleModule(
|
||||
|
@ -432,7 +437,7 @@ def main():
|
|||
except IOError:
|
||||
pass
|
||||
elif port:
|
||||
alt_connect_timeout = math.ceil((end - datetime.datetime.now()).total_seconds())
|
||||
alt_connect_timeout = math.ceil(_timedelta_total_seconds(end - datetime.datetime.now()))
|
||||
try:
|
||||
s = _create_connection((host, port), min(connect_timeout, alt_connect_timeout))
|
||||
except:
|
||||
|
@ -444,7 +449,7 @@ def main():
|
|||
data = ''
|
||||
matched = False
|
||||
while datetime.datetime.now() < end:
|
||||
max_timeout = math.ceil((end - datetime.datetime.now()).total_seconds())
|
||||
max_timeout = math.ceil(_timedelta_total_seconds(end - datetime.datetime.now()))
|
||||
(readable, w, e) = select.select([s], [], [], max_timeout)
|
||||
if not readable:
|
||||
# No new data. Probably means our timeout
|
||||
|
|
Loading…
Reference in a new issue