Skip to content

Conversation

ddelange
Copy link
Contributor

@ddelange ddelange commented Oct 14, 2025

Supersedes #357, follow-up on 8a35137

Comment on lines 316 to 317
# libmagic is not thread-safe: guard for concurrent calls on a global scope
LOCK = threading.Lock()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cclauss I realized there is no reason to allow passing a custom lock

@ddelange ddelange changed the title Free threading Make top level libmagic functions thread-safe, add free-threaded python to CI Oct 14, 2025
@ddelange ddelange force-pushed the free-threading branch 2 times, most recently from 74dfc08 to 79b6d26 Compare October 14, 2025 11:38
Copy link
Contributor

@cclauss cclauss left a comment

Choose a reason for hiding this comment

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

Looks good to me! Thanks.

@ddelange ddelange changed the title Make top level libmagic functions thread-safe, add free-threaded python to CI Add free-threaded python to CI including multithreading test Oct 17, 2025
@ddelange
Copy link
Contributor Author

simplified the diff here because the global libmagic functions are in fact thread-safe as long as you call them with a different cookie. so having the lock inside the Magic class is in fact correct.

@cclauss
Copy link
Contributor

cclauss commented Oct 17, 2025

Awesome!

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