def test_receive_synchronously_with_lease(publisher_client, topic, subscription_sync, capsys): _publish_messages(publisher_client, topic) subscriber.synchronous_pull_with_lease_management(PROJECT, SUBSCRIPTION_SYNC) out, _ = capsys.readouterr() assert "Done." in out
def test_receive_synchronously_with_lease(publisher_client, topic, subscription_sync, capsys): _publish_messages(publisher_client, topic) subscriber.synchronous_pull_with_lease_management(PROJECT_ID, SUBSCRIPTION_SYNC) out, _ = capsys.readouterr() assert f"Received and acknowledged 3 messages from {subscription_sync}." in out
def run_sample(): _publish_messages(publisher_client, topic, message_num=10) # Pausing 10s to allow the subscriber to establish the connection # because sync pull often returns fewer messages than requested. # The intention is to fix flaky tests reporting errors like # `google.api_core.exceptions.Unknown: None Stream removed` as # in https://github.com/googleapis/python-pubsub/issues/341. time.sleep(10) subscriber.synchronous_pull_with_lease_management(PROJECT_ID, SUBSCRIPTION_SYNC)
def run_sample(): _publish_messages(publisher_client, topic, message_num=3) subscriber.synchronous_pull_with_lease_management( PROJECT_ID, SUBSCRIPTION_SYNC)