本文整理匯總了Python中django.db.backends.BaseDatabaseWrapper.__dict__方法的典型用法代碼示例。如果您正苦於以下問題:Python BaseDatabaseWrapper.__dict__方法的具體用法?Python BaseDatabaseWrapper.__dict__怎麽用?Python BaseDatabaseWrapper.__dict__使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類django.db.backends.BaseDatabaseWrapper
的用法示例。
在下文中一共展示了BaseDatabaseWrapper.__dict__方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: patch_thread_ident
# 需要導入模塊: from django.db.backends import BaseDatabaseWrapper [as 別名]
# 或者: from django.db.backends.BaseDatabaseWrapper import __dict__ [as 別名]
def patch_thread_ident():
# monkey patch django.
# This patch make sure that we use real threads to get the ident which
# is going to happen if we are using gevent or eventlet.
# -- patch taken from gunicorn
if getattr(patch_thread_ident, 'called', False):
return
try:
from django.db.backends import BaseDatabaseWrapper, DatabaseError
if 'validate_thread_sharing' in BaseDatabaseWrapper.__dict__:
import thread
_get_ident = thread.get_ident
__old__init__ = BaseDatabaseWrapper.__init__
def _init(self, *args, **kwargs):
__old__init__(self, *args, **kwargs)
self._thread_ident = _get_ident()
def _validate_thread_sharing(self):
if (not self.allow_thread_sharing
and self._thread_ident != _get_ident()):
raise DatabaseError(
DB_SHARED_THREAD % (
self.alias, self._thread_ident, _get_ident()),
)
BaseDatabaseWrapper.__init__ = _init
BaseDatabaseWrapper.validate_thread_sharing = \
_validate_thread_sharing
patch_thread_ident.called = True
except ImportError:
pass