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

Fix unhandled exception in _has_connection() function #1226

Merged

Conversation

mtreinish
Copy link
Member

Summary

This commit address an issue where the socket calls we use to check if
there is external connectivity raises an exception that is no from the
socket lib. There are many reasons why this could occur including a
different class of network or firewall issue. To address all the
potential edge cases this changes the _has_connection() function to
treat any exception, not just those from the socket lib, as being unable
to connect and will return False.

Details and comments

Fixes #1225

This commit address an issue where the socket calls we use to check if
there is external connectivity raises an exception that is no from the
socket lib. There are many reasons why this could occur including a
different class of network or firewall issue. To address all the
potential edge cases this changes the _has_connection() function to
treat any exception, not just those from the socket lib, as being unable
to connect and will return False.

Fixes Qiskit#1225
@1ucian0
Copy link
Member

1ucian0 commented Nov 7, 2018

My understanding from the documentation is that is enough to catch IOError and ConnectionError. Can you take a look?

@mtreinish
Copy link
Member Author

I think you're correct those are the other likely errors raised by the socket lib for our calls. But there are still things like ValueError or TypeError being raised (although those are very uncommon). My thoughts here were that if any exception is raised during the connectivity check that means we can't establish connectivity. We don't want to raise an exception if testing the connectivity fails at all since that tells us we can't connect for whatever reason

@1ucian0 1ucian0 merged commit 4581327 into Qiskit:master Nov 7, 2018
lia-approves pushed a commit to edasgupta/qiskit-terra that referenced this pull request Jul 30, 2019
This commit address an issue where the socket calls we use to check if
there is external connectivity raises an exception that is no from the
socket lib. There are many reasons why this could occur including a
different class of network or firewall issue. To address all the
potential edge cases this changes the _has_connection() function to
treat any exception, not just those from the socket lib, as being unable
to connect and will return False.

Fixes Qiskit#1225
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.

ConnectionRefusedError when importing from qiskit.tools.visualization
3 participants