本文整理汇总了Python中django.core.signals.request_started.disconnect方法的典型用法代码示例。如果您正苦于以下问题:Python request_started.disconnect方法的具体用法?Python request_started.disconnect怎么用?Python request_started.disconnect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.core.signals.request_started
的用法示例。
在下文中一共展示了request_started.disconnect方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __enter__
# 需要导入模块: from django.core.signals import request_started [as 别名]
# 或者: from django.core.signals.request_started import disconnect [as 别名]
def __enter__(self):
self.force_debug_cursor = self.connection.force_debug_cursor
self.connection.force_debug_cursor = True
self.initial_queries = len(self.connection.queries_log)
self.final_queries = None
request_started.disconnect(reset_queries)
return self
示例2: __enter__
# 需要导入模块: from django.core.signals import request_started [as 别名]
# 或者: from django.core.signals.request_started import disconnect [as 别名]
def __enter__(self):
self.force_debug_cursor = self.connection.force_debug_cursor
self.connection.force_debug_cursor = True
# Run any initialization queries if needed so that they won't be
# included as part of the count.
self.connection.ensure_connection()
self.initial_queries = len(self.connection.queries_log)
self.final_queries = None
request_started.disconnect(reset_queries)
return self
示例3: __enter__
# 需要导入模块: from django.core.signals import request_started [as 别名]
# 或者: from django.core.signals.request_started import disconnect [as 别名]
def __enter__(self):
self.old_debug_cursor = self.connection.use_debug_cursor
self.connection.use_debug_cursor = True
self.starting_queries = len(self.connection.queries)
request_started.disconnect(reset_queries)
return self
示例4: __exit__
# 需要导入模块: from django.core.signals import request_started [as 别名]
# 或者: from django.core.signals.request_started import disconnect [as 别名]
def __exit__(self, exc_type, exc_value, traceback):
template_rendered.disconnect(self.on_template_render)
if exc_type is not None:
return
if not self.test():
message = self.message()
if len(self.rendered_templates) == 0:
message += ' No template was rendered.'
else:
message += ' Following templates were rendered: %s' % (
', '.join(self.rendered_template_names))
self.test_case.fail(message)
示例5: register_handlers
# 需要导入模块: from django.core.signals import request_started [as 别名]
# 或者: from django.core.signals.request_started import disconnect [as 别名]
def register_handlers(client):
from django.core.signals import got_request_exception, request_started, request_finished
from elasticapm.contrib.django.handlers import exception_handler
# Connect to Django's internal signal handlers
got_request_exception.disconnect(dispatch_uid=ERROR_DISPATCH_UID)
got_request_exception.connect(partial(exception_handler, client), dispatch_uid=ERROR_DISPATCH_UID, weak=False)
request_started.disconnect(dispatch_uid=REQUEST_START_DISPATCH_UID)
request_started.connect(
partial(_request_started_handler, client), dispatch_uid=REQUEST_START_DISPATCH_UID, weak=False
)
request_finished.disconnect(dispatch_uid=REQUEST_FINISH_DISPATCH_UID)
request_finished.connect(
lambda sender, **kwargs: client.end_transaction() if _should_start_transaction(client) else None,
dispatch_uid=REQUEST_FINISH_DISPATCH_UID,
weak=False,
)
# If we can import celery, register ourselves as exception handler
try:
import celery # noqa F401
from elasticapm.contrib.celery import register_exception_tracking
try:
register_exception_tracking(client)
except Exception as e:
client.logger.exception("Failed installing django-celery hook: %s" % e)
except ImportError:
client.logger.debug("Not instrumenting Celery, couldn't import")
示例6: setUp
# 需要导入模块: from django.core.signals import request_started [as 别名]
# 或者: from django.core.signals.request_started import disconnect [as 别名]
def setUp(self):
request_started.disconnect(close_old_connections)
示例7: tearDown
# 需要导入模块: from django.core.signals import request_started [as 别名]
# 或者: from django.core.signals.request_started import disconnect [as 别名]
def tearDown(self):
request_started.disconnect(self.register_started)
request_finished.disconnect(self.register_finished)
示例8: __enter__
# 需要导入模块: from django.core.signals import request_started [as 别名]
# 或者: from django.core.signals.request_started import disconnect [as 别名]
def __enter__(self):
self.force_debug_cursor = self.connection.force_debug_cursor
self.connection.force_debug_cursor = True
self.starting_count = len(self.connection.queries)
request_started.disconnect(reset_queries)
return self