Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Timeout Error catch #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Adding Timeout Error catch #15

wants to merge 1 commit into from

Conversation

mgagliardo
Copy link

So testing the lib I found out there is no catching for timeout exception (i.e. the cluster is down, the IP is wrong, etc.), this PR fixes that.

>>> import urllib3
>>>
>>> from purestorage import FlashArray
>>> from purestorage import PureError
>>>
>>> urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
>>>
>>> timeout=10
>>> cluster="MYIP"
>>>
>>> try:
...     array = FlashArray(cluster, api_token="MY_TOKEN", request_kwargs={'timeout':timeout})
... except PureError as err:
...     print("PureError timeout while connecting to the cluster {0}. Error: {1}".format(cluster, err))
...

PureError timeout while connecting to the cluster MYIP. Error: PureError: HTTPSConnectionPool(host='MYIP', port=443): Max retries exceeded with url: /api/api_version (Caused by ConnectTimeoutError(<urllib3.connection.VerifiedHTTPSConnection object at 0x7f9a89b05128>, 'Connection to MYIP timed out. (connect timeout=10)'))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant