From aba70943947f7c535cf596850171e5c9582d5894 Mon Sep 17 00:00:00 2001 From: Huanyi Xie <74809554+xiehuanyi@users.noreply.github.com> Date: Sun, 11 Oct 2026 10:03:15 +0300 Subject: [PATCH] docs: describe shared Magic identification calls --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c55f87c1..4bd907a3 100644 --- a/README.md +++ b/README.md @@ -24,9 +24,10 @@ functionality is exposed to the command line by the Unix command There is also a `Magic` class that provides more direct control, including overriding the magic database file and turning on character -encoding detection. This is not recommended for general use. In -particular, it's not safe for sharing across multiple threads and -will fail throw if this is attempted. +encoding detection. The identification methods `from_file`, `from_buffer`, and `from_descriptor` +serialize access with a per-instance lock, so those methods can be called +from multiple threads on the same instance. This does not cover concurrent +parameter changes through `setparam` or direct access to the libmagic cookie. ```python >>> f = magic.Magic(uncompress=True)