本文整理汇总了Python中pgq.consumer.Consumer.register_consumer方法的典型用法代码示例。如果您正苦于以下问题:Python Consumer.register_consumer方法的具体用法?Python Consumer.register_consumer怎么用?Python Consumer.register_consumer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pgq.consumer.Consumer
的用法示例。
在下文中一共展示了Consumer.register_consumer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: register_consumer
# 需要导入模块: from pgq.consumer import Consumer [as 别名]
# 或者: from pgq.consumer.Consumer import register_consumer [as 别名]
def register_consumer(self, provider_loc = None):
"""Register consumer on source node first, then target node."""
if not provider_loc:
provider_loc = self.options.provider
if not provider_loc:
self.log.error('Please give provider location with --provider=')
sys.exit(1)
dst_db = self.get_database(self.target_db)
dst_curs = dst_db.cursor()
src_db = self.get_database(PDB, connstr = provider_loc)
src_curs = src_db.cursor()
# check target info
q = "select * from pgq_node.get_node_info(%s)"
res = self.exec_cmd(src_db, q, [ self.queue_name ])
pnode = res[0]['node_name']
if not pnode:
raise Exception('parent node not initialized?')
# source queue
Consumer.register_consumer(self)
# fetch pos
q = "select last_tick from pgq.get_consumer_info(%s, %s)"
src_curs.execute(q, [self.queue_name, self.consumer_name])
last_tick = src_curs.fetchone()['last_tick']
if not last_tick:
raise Exception('registration failed?')
src_db.commit()
# target node
q = "select * from pgq_node.register_consumer(%s, %s, %s, %s)"
self.exec_cmd(dst_db, q, [self.queue_name, self.consumer_name, pnode, last_tick])
示例2: register_consumer
# 需要导入模块: from pgq.consumer import Consumer [as 别名]
# 或者: from pgq.consumer.Consumer import register_consumer [as 别名]
def register_consumer(self):
new = Consumer.register_consumer(self)
if new: # fixme
self.dst_reset()