Skip to content

PYTHON-2615 Reinstate TLS network timeout workaround due to eventlet #581

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

Merged
merged 1 commit into from
Mar 20, 2021

Conversation

ShaneHarvey
Copy link
Member

PYTHON-2616 Fix test_network_error_message when TLS is enabled.

PYTHON-2616 Fix test_network_error_message when TLS is enabled.
@@ -237,6 +237,12 @@ def _raise_connection_failure(address, error, msg_prefix=None):
msg = msg_prefix + msg
if isinstance(error, socket.timeout):
raise NetworkTimeout(msg) from error
elif isinstance(error, _SSLError) and 'timed out' in str(error):
# Eventlet does not distinguish TLS network timeouts from other
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am wondering since this is only occurring when eventlet is installed should we check whether eventlet is installed (I don't know if its possible - I feel like it should be) inside this elif?

Copy link
Member Author

@ShaneHarvey ShaneHarvey Mar 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No we can't check if eventlet is installed. Merely importing eventlet can have side effects like we saw in the dnspython 2.0 vs eventlet bug (see #484 (comment)).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see.
Using __import__ will actually eliminate any side effects as it doesn't mess with the current global/local namespaces (unless instructed to do so) but I take your point that checking eventlet in any form would present a risk with minimal reward.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think __import__ can prevent the types of issues we saw in #484 (comment)

@ShaneHarvey ShaneHarvey merged commit 80adc13 into mongodb:master Mar 20, 2021
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.

2 participants