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

Cache truststore SSLContext as load_verify_locations() is slow #13199

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

Conversation

ichard26
Copy link
Member

@ichard26 ichard26 commented Feb 2, 2025

SSLContext can be reused across connections as per the Python docs:

SSLContext is designed to be shared and used by multiple connections. Thus, it is thread-safe as long as it is not reconfigured after being used by a connection.

In addition, requests has been using a global SSLContext and the sky hasn't fallen on them so I'm going to say this is pretty safe.

See also python/cpython#95031.

SSLContext can be reused across connections as per the Python docs:

> SSLContext is designed to be shared and used by multiple connections.
> Thus, it is thread-safe as long as it is not reconfigured after being
> used by a connection.

In addition, requests has been using a global SSLContext and the world
hasn't blown up so I'm going to say this is pretty safe.
@ichard26 ichard26 added skip news Does not need a NEWS file entry (eg: trivial changes) type: performance Commands take too long to run labels Feb 2, 2025
@ichard26
Copy link
Member Author

ichard26 commented Feb 2, 2025

I didn't include a news entry as the benefit is not significant, but when you combine all of the verify location/path loads in a typical run, they consume ~75 ms (~15ms/load) on my system. This eliminates one load from the self-check session, and sethmlarson/truststore#171 will eliminate one load from truststore's intialization. I may include a news entry for the optimization work in general once it's done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip news Does not need a NEWS file entry (eg: trivial changes) type: performance Commands take too long to run
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant