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

PYTHON-4440 - Add executor thread limit for pyopenssl_context #1690

Closed
wants to merge 2 commits into from

Conversation

NoahStapp
Copy link
Contributor

No description provided.

@ShaneHarvey ShaneHarvey self-requested a review June 17, 2024 19:39
Copy link
Member

@ShaneHarvey ShaneHarvey left a comment

Choose a reason for hiding this comment

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

I think it's better to use the loop's default executor in this case. That way we don't need to create extra threads when the app uses run_in_executor in other places executor. Also, maxConnecting is not a concern here because it's enforced at a higher level.

@NoahStapp
Copy link
Contributor Author

I think it's better to use the loop's default executor in this case. That way we don't need to create extra threads when the app uses run_in_executor in other places executor. Also, maxConnecting is not a concern here because it's enforced at a higher level.

This PR addresses the case we discussed last week where if you keep opening new connections, it could use one thread per connection, which is not scalable.

@ShaneHarvey
Copy link
Member

ShaneHarvey commented Jun 17, 2024

The tradeoffs here are not worthwhile in my opinion. For example, now if more that 2 connections are in progress, we'll add latency to connection creation. Consider that maxConnecting only limits one pool in one client, while this newly added executor limits all pools of all clients.

If we're going to use run_in_executor, we should just use the default behavior. PYTHON-4440 should be the ticket to replace run_in_executor with real asyncio native OCSP.

@NoahStapp
Copy link
Contributor Author

NoahStapp commented Jun 17, 2024

The tradeoffs here are not worthwhile in my opinion. For example, now if more that 2 connections are in progress, we'll add latency to connection creation. Consider that maxConnecting only limits one pool in one client, while this newly added executor limits all pools of all clients.

If we're going to use run_in_executor, we should just use the default behavior. PYTHON-4440 should be the ticket to replace run_in_executor with real asyncio native OCSP.

PyOpenSSL does not have a native async API. Asyncio does have some native SSL support, especially around do_handshake, but we need async implementations of both do_handshake and request_ocsp. One option would be for us to write our own native async implementations for both functions.

Absent a different library with native async support for these interfaces, we're left with running synchronous code using run_in_executor.

@ShaneHarvey
Copy link
Member

Right I expect PYTHON-4440 to be left in the backlog indefinitely until stdlib ssl or pyopenssl gains async support for OCSP. For now, we can keep using the loop's default executor behavior.

@NoahStapp
Copy link
Contributor Author

Right I expect PYTHON-4440 to be left in the backlog indefinitely until stdlib ssl or pyopenssl gains async support for OCSP. For now, we can keep using the loop's default executor behavior.

Got it! Sorry, I thought we had said we wanted to change this behavior now, not wait for an external update to the libraries.

@NoahStapp NoahStapp closed this Jun 17, 2024
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