Skip to content

Commit

Permalink
Set timeout to infinite for publishing with ordering keys enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
mukund-ananthu committed Apr 3, 2024
1 parent 8c7e2a9 commit 5db95f4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 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,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)
Expand Down
5 changes: 3 additions & 2 deletions tests/unit/pubsub_v1/publisher/test_publisher_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@

import pytest
import time
from typing import cast

from google.api_core import gapic_v1
from google.api_core import retry as retries
from google.api_core.gapic_v1.client_info import METRICS_METADATA_KEY
from google.cloud.pubsub_v1 import publisher
from google.cloud.pubsub_v1 import types
from google.cloud.pubsub_v1 import PublisherTransport

from google.cloud.pubsub_v1.publisher import exceptions
from google.cloud.pubsub_v1.publisher._sequencer import ordered_sequencer
Expand Down Expand Up @@ -313,7 +315,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)


Expand Down Expand Up @@ -342,7 +344,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)

Expand Down

0 comments on commit 5db95f4

Please sign in to comment.