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


Python CascadedConsumer.is_batch_done方法代码示例

本文整理汇总了Python中pgq.cascade.consumer.CascadedConsumer.is_batch_done方法的典型用法代码示例。如果您正苦于以下问题:Python CascadedConsumer.is_batch_done方法的具体用法?Python CascadedConsumer.is_batch_done怎么用?Python CascadedConsumer.is_batch_done使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pgq.cascade.consumer.CascadedConsumer的用法示例。


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

示例1: is_batch_done

# 需要导入模块: from pgq.cascade.consumer import CascadedConsumer [as 别名]
# 或者: from pgq.cascade.consumer.CascadedConsumer import is_batch_done [as 别名]
    def is_batch_done(self, state, batch_info):
        wst = self._worker_state

        # on combined-branch the target can get several batches ahead
        if wst.wait_behind:
            cur_tick = batch_info['tick_id']
            dst_tick = state['completed_tick']
            if cur_tick < dst_tick:
                return True

        return CascadedConsumer.is_batch_done(self, state, batch_info)
开发者ID:famoseagle,项目名称:skytools,代码行数:13,代码来源:worker.py

示例2: is_batch_done

# 需要导入模块: from pgq.cascade.consumer import CascadedConsumer [as 别名]
# 或者: from pgq.cascade.consumer.CascadedConsumer import is_batch_done [as 别名]
    def is_batch_done(self, state, batch_info, dst_db):
        wst = self._worker_state

        # on combined-branch the target can get several batches ahead
        if wst.wait_behind:
            cur_tick = batch_info['tick_id']
            dst_tick = state['completed_tick']
            if cur_tick < dst_tick:
                return True

        # check if events have processed
        done = CascadedConsumer.is_batch_done(self, state, batch_info, dst_db)
        if not wst.create_tick:
            return done
        if not done:
            return False

        # check if tick is done - it happens in separate tx

        # fetch last tick from target queue
        q = "select t.tick_id from pgq.tick t, pgq.queue q"\
            " where t.tick_queue = q.queue_id and q.queue_name = %s"\
            " order by t.tick_queue desc, t.tick_id desc"\
            " limit 1"
        curs = dst_db.cursor()
        curs.execute(q, [self.queue_name])
        last_tick = curs.fetchone()['tick_id']
        dst_db.commit()

        # insert tick if missing
        cur_tick = batch_info['tick_id']
        if last_tick != cur_tick:
            prev_tick = batch_info['prev_tick_id']
            tick_time = batch_info['batch_end']
            if last_tick != prev_tick:
                raise Exception('is_batch_done: last branch tick = %d, expected %d or %d' % (
                                last_tick, prev_tick, cur_tick))
            self.create_branch_tick(dst_db, cur_tick, tick_time)
        return True
开发者ID:cbbrowne,项目名称:skytools,代码行数:41,代码来源:worker.py


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