如何查看 google pub/sub 何时完成

从客户那里,我有以下代码:


publisher = pubsub_v1.PublisherClient()

topic_path = publisher.topic_path(project_id, topic_name)

future = publisher.publish(topic_path, data=json.dumps(dict(op='create_master', review_id=1273612)))

有没有办法检查项目何时完成处理?如果是这样,那将如何进行?现在,我无法知道某人是否“有效”。


繁星点点滴滴
浏览 167回答 2
2回答

皈依舞

设置它的一种方法是将其存储在基于message_id. 例如,这里是一些示例服务器代码:def callback(message):    # Message has been received by the Server/Subscriber    cursor.execute('INSERT IGNORE INTO pubsub (id, message, received) VALUES (%s, %s, NOW())', (message.message_id, message.data))    connection.commit()    # Message is processed by the Server/Subscriber    data_obj = loads(message.data)    _process(data_obj)    # Message has finished being processed by the Server/Subscriber    cursor.execute('UPDATE pubsub SET completed=NOW() WHERE id=%s', (message.message_id,))    connection.commit()    message.ack()客户端可以id通过访问future.result(),因此可以轻松查询以查看状态。如果在单独的进程中查看状态(例如,如果 100 个长时间运行的进程正在运行并且我们想要跟踪哪些已完成),这会特别有用。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python