Skip to content

Commit

Permalink
Ensure suppressing urllib3 warning works correctly
Browse files Browse the repository at this point in the history
On some platforms (RHEL7 using ansible) the warnings are not being suppressed.
Looking into this, the try-except block failed with the error `cannot import name InsecurePlatformWarning`.
So it is safer to import and filter each warning individually.

This fixes ansible/ansible#20006
  • Loading branch information
dagwieers committed Aug 20, 2017
1 parent b1a54bc commit ee6a92d
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion winrm/transport.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from __future__ import unicode_literals
from contextlib import contextmanager
import errno
import re
import sys
import os
import time
import weakref

is_py2 = sys.version[0] == '2'
Expand Down Expand Up @@ -189,7 +191,18 @@ def send_message(self, message):
prepared_request = self.session.prepare_request(request)

try:
response = self.session.send(prepared_request, timeout=self.read_timeout_sec)

for retry in range(5):
try:
response = self.session.send(prepared_request, timeout=self.read_timeout_sec)
break
except requests.exceptions.ConnectionError as e:
if e.args[0].reason.errno != errno.ECONNREFUSED:
raise
elif retry == 4:
raise
time.sleep(5)

response_text = response.text
response.raise_for_status()
return response_text
Expand Down

0 comments on commit ee6a92d

Please sign in to comment.