0
在看了一下Django的源代碼之後,我發現Django在當前線程中存儲了活動語言。翻譯Django中的greenlet-safe?
在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安全的嗎?我使用gunicorn運行Django,配置爲運行「綠色」gevent工作者。是local()
由gevent猴子補丁?或者,在使用gevent時,是否存在使用其他請求的活動語言提供請求的競爭條件?
謝謝。