File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed
tests/unit/pubsub_v1/publisher Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change 3535from google .protobuf import timestamp_pb2
3636
3737from google .api_core .protobuf_helpers import get_messages
38+ from google .api_core .timeout import ExponentialTimeout
3839
3940from google .pubsub_v1 .types import pubsub as pubsub_gapic_types
4041
@@ -191,7 +192,12 @@ class PublisherOptions(NamedTuple):
191192 "an instance of :class:`google.api_core.retry.Retry`."
192193 )
193194
194- timeout : "OptionalTimeout" = gapic_v1 .method .DEFAULT # use api_core default
195+ # Use ExponentialTimeout instead of api_core default because the default
196+ # value results in retries with zero deadline.
197+ # Refer https://github.com/googleapis/python-api-core/issues/654
198+ timeout : "OptionalTimeout" = ExponentialTimeout (
199+ initial = 5 , maximum = 60 , multiplier = 1.3 , deadline = 600
200+ )
195201 (
196202 "Timeout settings for message publishing by the client. It should be "
197203 "compatible with :class:`~.pubsub_v1.types.TimeoutType`."
Original file line number Diff line number Diff line change 3535from google .api_core import gapic_v1
3636from google .api_core import retry as retries
3737from google .api_core .gapic_v1 .client_info import METRICS_METADATA_KEY
38+ from google .api_core .timeout import ExponentialTimeout
3839
3940from google .cloud .pubsub_v1 import publisher
4041from google .cloud .pubsub_v1 import types
@@ -660,7 +661,9 @@ def test_publish_new_batch_needed(creds):
660661 batch_done_callback = None ,
661662 commit_when_full = True ,
662663 commit_retry = gapic_v1 .method .DEFAULT ,
663- commit_timeout = gapic_v1 .method .DEFAULT ,
664+ commit_timeout = ExponentialTimeout (
665+ initial = 5 , maximum = 60 , multiplier = 1.3 , deadline = 600
666+ ),
664667 )
665668 message_pb = gapic_types .PubsubMessage (data = b"foo" , attributes = {"bar" : "baz" })
666669 wrapper = PublishMessageWrapper (message = message_pb )
You can’t perform that action at this time.
0 commit comments