Django のソース コードを調べたところ、Django がアクティブな言語を現在のスレッドに格納していることがわかります。
でdjango.utils.translation.trans_real
:
_active = local()
...
def activate(language):
"""
Fetches the translation object for a given tuple of application name and
language and installs it as the current translation object for the current
thread.
"""
_active.value = translation(language)
これで問題ありませんが、greenlet-safe かどうかはわかりません。「グリーン」geventワーカーを実行するように構成されたgunicornでDjangoを実行しています。geventlocal()
によってモンキー パッチが適用されますか? または、gevent を使用しているときに別のリクエストのアクティブな言語を使用してリクエストが処理される可能性があるという競合状態はありますか?
ありがとう。