我有一个订户应用程序,它使用google-cloud-pubsub python库从Google Cloud Pub / Sub异步提取。
我遇到间歇性问题,我的回调函数未完成运行/被中断。不幸的是,我没有任何错误,我只知道是这种情况,因为它没有完成向外部源的数据写入。
例如,在以下示例代码中:
subscriber = pubsub_v1.SubscriberClient()
subscription_path = subscriber.subscription_path(
project, subscription_name)
def callback(message):
print('Received message: {}'.format(message))
message.ack()
# Limit the subscriber to only have ten outstanding messages at a time.
flow_control = pubsub_v1.types.FlowControl(max_messages=10)
subscriber.subscribe(
subscription_path, callback=callback, flow_control=flow_control)
# The subscriber is non-blocking, so we must keep the main thread from
# exiting to allow it to process messages in the background.
print('Listening for messages on {}'.format(subscription_path))
while True:
time.sleep(60)
回调函数中的代码有时可能需要一段时间,在某些情况下,我注意到它还没有完成执行/似乎被某些事情打乱了。
有可能发生吗?该功能有超时时间吗?