From 302eb456728427b40fb80e413409be77ee11f0d4 Mon Sep 17 00:00:00 2001 From: Mukund Ananthu Date: Wed, 3 Apr 2024 18:09:36 +0000 Subject: [PATCH] Set timeout to infinite for publishing with ordering keys enabled --- google/cloud/pubsub_v1/publisher/client.py | 2 ++ tests/unit/pubsub_v1/publisher/test_publisher_client.py | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/google/cloud/pubsub_v1/publisher/client.py b/google/cloud/pubsub_v1/publisher/client.py index caf9fa180..9afe3713f 100644 --- a/google/cloud/pubsub_v1/publisher/client.py +++ b/google/cloud/pubsub_v1/publisher/client.py @@ -399,8 +399,10 @@ def on_publish_done(future): transport = self._transport base_retry = transport._wrapped_methods[transport.publish]._retry retry = base_retry.with_deadline(2.0**32) + timeout = 2.0**32 elif retry is not None: retry = retry.with_deadline(2.0**32) + timeout = 2.0**32 # Delegate the publishing to the sequencer. sequencer = self._get_or_create_sequencer(topic, ordering_key) diff --git a/tests/unit/pubsub_v1/publisher/test_publisher_client.py b/tests/unit/pubsub_v1/publisher/test_publisher_client.py index cc8eda56c..64609cea3 100644 --- a/tests/unit/pubsub_v1/publisher/test_publisher_client.py +++ b/tests/unit/pubsub_v1/publisher/test_publisher_client.py @@ -313,7 +313,7 @@ def test_publish_with_ordering_key_uses_extended_retry_deadline(creds): _, kwargs = batch_class.call_args batch_commit_retry = kwargs["commit_retry"] - expected_retry = custom_retry.with_deadline(2.0**32) + expected_retry = custom_retry.with_deadline(2.0**32).with_timeout(2.0**32) _assert_retries_equal(batch_commit_retry, expected_retry) @@ -342,7 +342,6 @@ def test_publish_with_ordering_key_with_no_retry(creds): # Check the retry settings used for the batch. batch_class.assert_called_once() - def test_publish_attrs_bytestring(creds): client = publisher.Client(credentials=creds)