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

Update documentation to clearly state that Fernet is thread safe #12488

Open
dan-corneanu opened this issue Feb 19, 2025 · 4 comments
Open

Update documentation to clearly state that Fernet is thread safe #12488

dan-corneanu opened this issue Feb 19, 2025 · 4 comments

Comments

@dan-corneanu
Copy link

I recently used Fernet in a multithreaded environment and struggled to determine from the documentation whether it is thread-safe.

After reviewing the implementation, it appears that Fernet is indeed thread-safe:
Source Code

Would it be appropriate to update the documentation to clarify this?

@alex
Copy link
Member

alex commented Feb 19, 2025

Every immutable object in cryptography is safe to share between multiple threads. (Mutable objects, like hash contexts, can also safely be shared, but concurrent mutation will produce indefinite results or raise an exception).

This is by way of saying: this isn't specific to fernet, so I think if we want to add something to the docs, we probably want to make it more general purpose.

Are you interested in submitting a PR?

@dan-corneanu
Copy link
Author

dan-corneanu commented Feb 22, 2025 via email

@alex
Copy link
Member

alex commented Feb 22, 2025

Great, thanks.

@ngoldbaum
Copy link
Contributor

I'm also happy to help out with this in the context of free-threaded Python.

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

No branches or pull requests

3 participants