Thread safety#

Most functions and classes are thread safe. Notable exceptions are documented here.

Not thread safe

Comment

enable_verbose_debug_messages()

This function modifies global state.

AbstractFetcher.fetch_all()

When selective_fetch_all=True (default), a temporary Mapper instance may be used. All built-in fetchers (e.g. the SqlFetcher) inherit from this class.

Fetcher.initialize_sources()

Invoked implicitly before all translation tasks. Results are cached when using a MultiFetcher or AbstractFetcher subtype, after which initialize_sources is thread-safe for these types.

Translator.translated_names()

Reflects the most recent Translator.translate() call on the instance. The translate call itself is thread safe (when copy=True), but the recorded names are not. Use Translator.map() in multi-threaded contexts.

Translator.initialize_sources()

Delegates to Fetcher.initialize_sources above, so the same “first call is not thread safe” caveat applies. The first call also registers fetcher-provided transformers (see Fetcher.get_transformer()), mutating the Translator itself. translate() triggers this implicitly on its own first call and inherits the same caveat.

Translator.go_offline()

Performs Fetcher teardown. Once offline, the Translator is safe to share.

Transformers#

The Translator.transformers are reused for all translation tasks. Bundled Transformer types are thread safe. Transformers are inherited by any TranslationMap instances created by the Translator, including the Translator.cache created by Translator.go_offline(). Note that Translator.register_transformer() mutates shared state (including the cache), so the safe-to-share guarantee above assumes no registrations are made after going offline. See the registration window for details.

Fetchers#

Some thread-unsafe Fetcher operations emit a ConcurrentOperationWarning on a best-effort basis when entered from multiple threads at once. This detection is cheap and lock-free, so it may miss races; absence of a warning does not prove correctness.