当前位置: 首页>>代码示例>>Python>>正文


Python db.reset_queries函数代码示例

本文整理汇总了Python中zerver.lib.db.reset_queries函数的典型用法代码示例。如果您正苦于以下问题:Python reset_queries函数的具体用法?Python reset_queries怎么用?Python reset_queries使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了reset_queries函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: start

 def start(self) -> None:  # nocoverage
     while True:
         # TODO: Probably it'd be better to share code with consume_wrapper()
         events = self.q.drain_queue(self.queue_name, json=True)
         try:
             self.consume_batch(events)
         finally:
             reset_queries()
         time.sleep(self.sleep_delay)
开发者ID:BakerWang,项目名称:zulip,代码行数:9,代码来源:queue_processors.py

示例2: record_request_start_data

def record_request_start_data(log_data: MutableMapping[str, Any]) -> None:
    if settings.PROFILE_ALL_REQUESTS:
        log_data["prof"] = cProfile.Profile()
        log_data["prof"].enable()

    reset_queries()
    log_data['time_started'] = time.time()
    log_data['remote_cache_time_start'] = get_remote_cache_time()
    log_data['remote_cache_requests_start'] = get_remote_cache_requests()
    log_data['bugdown_time_start'] = get_bugdown_time()
    log_data['bugdown_requests_start'] = get_bugdown_requests()
开发者ID:akashnimare,项目名称:zulip,代码行数:11,代码来源:middleware.py

示例3: consume_wrapper

 def consume_wrapper(self, data):
     try:
         self.consume(data)
     except Exception:
         self._log_problem()
         if not os.path.exists(settings.QUEUE_ERROR_DIR):
             os.mkdir(settings.QUEUE_ERROR_DIR)
         fname = '%s.errors' % (self.queue_name,)
         fn = os.path.join(settings.QUEUE_ERROR_DIR, fname)
         line = u'%s\t%s\n' % (time.asctime(), ujson.dumps(data))
         lock_fn = fn + '.lock'
         with lockfile(lock_fn):
             with open(fn, 'ab') as f:
                 f.write(line.encode('utf-8'))
     reset_queries()
开发者ID:150vb,项目名称:zulip,代码行数:15,代码来源:queue_processors.py

示例4: process_one_batch

    def process_one_batch(self):
        slow_queries = self.q.drain_queue("slow_queries", json=True)

        if settings.ERROR_BOT is None:
            return

        if len(slow_queries) > 0:
            topic = "%s: slow queries" % (settings.EXTERNAL_HOST,)

            content = ""
            for query in slow_queries:
                content += "    %s\n" % (query,)

            internal_send_message(settings.ERROR_BOT, "stream", "logs", topic, content)

        reset_queries()
开发者ID:150vb,项目名称:zulip,代码行数:16,代码来源:queue_processors.py

示例5: start

    def start(self):
        while True:
            missed_events = self.q.drain_queue("missedmessage_emails", json=True)
            by_recipient = defaultdict(list) # type: Dict[int, List[Dict[str, Any]]]

            for event in missed_events:
                logging.info("Received event: %s" % (event,))
                by_recipient[event['user_profile_id']].append(event)

            for user_profile_id, events in by_recipient.items():
                handle_missedmessage_emails(user_profile_id, events)

            reset_queries()
            # Aggregate all messages received every 2 minutes to let someone finish sending a batch
            # of messages
            time.sleep(2 * 60)
开发者ID:150vb,项目名称:zulip,代码行数:16,代码来源:queue_processors.py

示例6: consume_wrapper

 def consume_wrapper(self, data: Dict[str, Any]) -> None:
     try:
         self.consume(data)
     except Exception:
         self._log_problem()
         if not os.path.exists(settings.QUEUE_ERROR_DIR):
             os.mkdir(settings.QUEUE_ERROR_DIR)  # nocoverage
         fname = '%s.errors' % (self.queue_name,)
         fn = os.path.join(settings.QUEUE_ERROR_DIR, fname)
         line = '%s\t%s\n' % (time.asctime(), ujson.dumps(data))
         lock_fn = fn + '.lock'
         with lockfile(lock_fn):
             with open(fn, 'ab') as f:
                 f.write(line.encode('utf-8'))
         check_and_send_restart_signal()
     finally:
         reset_queries()
开发者ID:BakerWang,项目名称:zulip,代码行数:17,代码来源:queue_processors.py

示例7: process_one_batch

    def process_one_batch(self):
        # type: () -> None
        slow_queries = self.q.drain_queue("slow_queries", json=True)

        if settings.ERROR_BOT is None:
            return

        if len(slow_queries) > 0:
            topic = "%s: slow queries" % (settings.EXTERNAL_HOST,)

            content = ""
            for query in slow_queries:
                content += "    %s\n" % (query,)

            error_bot_realm = get_user_profile_by_email(settings.ERROR_BOT).realm
            internal_send_message(error_bot_realm, settings.ERROR_BOT,
                                  "stream", "logs", topic, content)

        reset_queries()
开发者ID:aakash-cr7,项目名称:zulip,代码行数:19,代码来源:queue_processors.py


注:本文中的zerver.lib.db.reset_queries函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。