Skip to content

Commit 67daf3c

Browse files
fix: Set timeout to infinite for publishing with ordering keys enabled (#1134)
1 parent 8c7e2a9 commit 67daf3c

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

google/cloud/pubsub_v1/publisher/client.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,8 +399,13 @@ def on_publish_done(future):
399399
transport = self._transport
400400
base_retry = transport._wrapped_methods[transport.publish]._retry
401401
retry = base_retry.with_deadline(2.0**32)
402+
# timeout needs to be overridden and set to infinite in
403+
# addition to the retry deadline since both determine
404+
# the duration for which retries are attempted.
405+
timeout = 2.0**32
402406
elif retry is not None:
403407
retry = retry.with_deadline(2.0**32)
408+
timeout = 2.0**32
404409

405410
# Delegate the publishing to the sequencer.
406411
sequencer = self._get_or_create_sequencer(topic, ordering_key)

tests/unit/pubsub_v1/publisher/test_publisher_client.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,10 @@ def test_publish_with_ordering_key_uses_extended_retry_deadline(creds):
316316
expected_retry = custom_retry.with_deadline(2.0**32)
317317
_assert_retries_equal(batch_commit_retry, expected_retry)
318318

319+
batch_commit_timeout = kwargs["commit_timeout"]
320+
expected_timeout = 2.0**32
321+
assert batch_commit_timeout == pytest.approx(expected_timeout)
322+
319323

320324
def test_publish_with_ordering_key_with_no_retry(creds):
321325
client = publisher.Client(

0 commit comments

Comments
 (0)