當前位置: 首頁>>代碼示例>>Python>>正文


Python request_started.connect方法代碼示例

本文整理匯總了Python中django.core.signals.request_started.connect方法的典型用法代碼示例。如果您正苦於以下問題:Python request_started.connect方法的具體用法?Python request_started.connect怎麽用?Python request_started.connect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在django.core.signals.request_started的用法示例。


在下文中一共展示了request_started.connect方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __exit__

# 需要導入模塊: from django.core.signals import request_started [as 別名]
# 或者: from django.core.signals.request_started import connect [as 別名]
def __exit__(self, exc_type, exc_value, traceback):
        self.connection.force_debug_cursor = self.force_debug_cursor
        request_started.connect(reset_queries)
        if exc_type is not None:
            return
        self.final_queries = len(self.connection.queries_log) 
開發者ID:lanbing510,項目名稱:GTDWeb,代碼行數:8,代碼來源:utils.py

示例2: __exit__

# 需要導入模塊: from django.core.signals import request_started [as 別名]
# 或者: from django.core.signals.request_started import connect [as 別名]
def __exit__(self, exc_type, exc_value, traceback):
        self.connection.use_debug_cursor = self.old_debug_cursor
        request_started.connect(reset_queries)
        if exc_type is not None:
            return

        final_queries = len(self.connection.queries)
        executed = final_queries - self.starting_queries

        self.test_case.assertEqual(
            executed, self.num, "%d queries executed, %d expected" % (
                executed, self.num
            )
        ) 
開發者ID:blackye,項目名稱:luscan-devel,代碼行數:16,代碼來源:testcases.py

示例3: __enter__

# 需要導入模塊: from django.core.signals import request_started [as 別名]
# 或者: from django.core.signals.request_started import connect [as 別名]
def __enter__(self):
        template_rendered.connect(self.on_template_render)
        return self 
開發者ID:blackye,項目名稱:luscan-devel,代碼行數:5,代碼來源:testcases.py

示例4: register_handlers

# 需要導入模塊: from django.core.signals import request_started [as 別名]
# 或者: from django.core.signals.request_started import connect [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") 
開發者ID:elastic,項目名稱:apm-agent-python,代碼行數:33,代碼來源:apps.py

示例5: ready

# 需要導入模塊: from django.core.signals import request_started [as 別名]
# 或者: from django.core.signals.request_started import connect [as 別名]
def ready(self):
        request_started.connect(check_apps_need_reloading) 
開發者ID:propublica,項目名稱:django-collaborative,代碼行數:4,代碼來源:apps.py

示例6: tearDown

# 需要導入模塊: from django.core.signals import request_started [as 別名]
# 或者: from django.core.signals.request_started import connect [as 別名]
def tearDown(self):
        request_started.connect(close_old_connections) 
開發者ID:nesdis,項目名稱:djongo,代碼行數:4,代碼來源:tests.py

示例7: setUp

# 需要導入模塊: from django.core.signals import request_started [as 別名]
# 或者: from django.core.signals.request_started import connect [as 別名]
def setUp(self):
        self.signals = []
        self.signaled_environ = None
        request_started.connect(self.register_started)
        request_finished.connect(self.register_finished) 
開發者ID:nesdis,項目名稱:djongo,代碼行數:7,代碼來源:tests.py

示例8: __exit__

# 需要導入模塊: from django.core.signals import request_started [as 別名]
# 或者: from django.core.signals.request_started import connect [as 別名]
def __exit__(self, exc_type, exc_value, traceback):
        self.connection.force_debug_cursor = self.force_debug_cursor
        request_started.connect(reset_queries)
        if exc_type is not None:
            return
        final_count = len(self.connection.queries)
        self.num_queries = final_count - self.starting_count 
開發者ID:maas,項目名稱:maas,代碼行數:9,代碼來源:djangotestcase.py


注:本文中的django.core.signals.request_started.connect方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。