Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Set timeout to infinite for publishing with ordering keys enabled #1134

Merged
merged 1 commit into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions google/cloud/pubsub_v1/publisher/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,13 @@ 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 needs to be overridden and set to infinite in
# addition to the retry deadline since both determine
# the duration for which retries are attempted.
timeout = 2.0**32
mukund-ananthu marked this conversation as resolved.
Show resolved Hide resolved
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)
Expand Down
4 changes: 4 additions & 0 deletions tests/unit/pubsub_v1/publisher/test_publisher_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,10 @@ def test_publish_with_ordering_key_uses_extended_retry_deadline(creds):
expected_retry = custom_retry.with_deadline(2.0**32)
_assert_retries_equal(batch_commit_retry, expected_retry)

batch_commit_timeout = kwargs["commit_timeout"]
expected_timeout = 2.0**32
assert batch_commit_timeout == pytest.approx(expected_timeout)


def test_publish_with_ordering_key_with_no_retry(creds):
client = publisher.Client(
Expand Down