Skip to content

runtime: guard FluentLocalization._bundles against concurrent generator access#222

Open
SAY-5 wants to merge 1 commit into
projectfluent:mainfrom
SAY-5:fix-fallback-thread-safety
Open

runtime: guard FluentLocalization._bundles against concurrent generator access#222
SAY-5 wants to merge 1 commit into
projectfluent:mainfrom
SAY-5:fix-fallback-thread-safety

Conversation

@SAY-5
Copy link
Copy Markdown

@SAY-5 SAY-5 commented May 31, 2026

FluentLocalization._bundles calls next(self._bundle_it) on the shared _iterate_bundles() generator without synchronisation, so concurrent format_value / format_message calls from multiple threads can re-enter the generator and raise ValueError: generator already executing. Add a per-instance threading.Lock around the cache-extension step (with a double-check so cached lookups stay lock-free) and a regression test that drives 8 threads through format_value.

Closes #221

…or access

Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
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.

ValueError: generator already executing when multithreading

1 participant