本文整理汇总了Python中pgq.cascade.consumer.CascadedConsumer.finish_remote_batch方法的典型用法代码示例。如果您正苦于以下问题:Python CascadedConsumer.finish_remote_batch方法的具体用法?Python CascadedConsumer.finish_remote_batch怎么用?Python CascadedConsumer.finish_remote_batch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pgq.cascade.consumer.CascadedConsumer
的用法示例。
在下文中一共展示了CascadedConsumer.finish_remote_batch方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: finish_remote_batch
# 需要导入模块: from pgq.cascade.consumer import CascadedConsumer [as 别名]
# 或者: from pgq.cascade.consumer.CascadedConsumer import finish_remote_batch [as 别名]
def finish_remote_batch(self, src_db, dst_db, tick_id):
"""Worker-specific cleanup on target node.
"""
# merge-leaf on branch should not update tick pos
wst = self._worker_state
if wst.wait_behind:
dst_db.commit()
return
if self.main_worker:
st = self._worker_state
dst_curs = dst_db.cursor()
self.flush_events(dst_curs)
# send tick event into queue
if st.send_tick_event:
q = "select pgq.insert_event(%s, 'pgq.tick-id', %s, %s, null, null, null)"
dst_curs.execute(q, [st.target_queue, str(tick_id), self.pgq_queue_name])
CascadedConsumer.finish_remote_batch(self, src_db, dst_db, tick_id)
if self.main_worker:
if st.create_tick:
# create actual tick
tick_id = self.batch_info['tick_id']
tick_time = self.batch_info['batch_end']
self.create_branch_tick(dst_db, tick_id, tick_time)
示例2: finish_remote_batch
# 需要导入模块: from pgq.cascade.consumer import CascadedConsumer [as 别名]
# 或者: from pgq.cascade.consumer.CascadedConsumer import finish_remote_batch [as 别名]
def finish_remote_batch(self, src_db, dst_db, tick_id):
"""Worker-specific cleanup on target node.
"""
if self.main_worker:
st = self._worker_state
dst_curs = dst_db.cursor()
self.flush_events(dst_curs)
# send tick event into queue
if st.send_tick_event:
q = "select pgq.insert_event(%s, 'pgq.tick-id', %s, %s, null, null, null)"
dst_curs.execute(q, [st.target_queue, str(tick_id), self.pgq_queue_name])
if st.create_tick:
# create actual tick
tick_id = self._batch_info['tick_id']
tick_time = self._batch_info['batch_end']
q = "select pgq.ticker(%s, %s, %s, %s)"
dst_curs.execute(q, [self.pgq_queue_name, tick_id, tick_time, self.cur_max_id])
CascadedConsumer.finish_remote_batch(self, src_db, dst_db, tick_id)