Skip to content

Commit e4b5810

Browse files
authored
Merge branch 'main' into set-creds-to-transport
2 parents ec9ddcf + 32d0998 commit e4b5810

File tree

7 files changed

+25
-5
lines changed

7 files changed

+25
-5
lines changed

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
".": "2.27.2"
2+
".": "2.27.3"
33
}
44

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55
[1]: https://pypi.org/project/google-cloud-pubsub/#history
66

77

8+
## [2.27.3](https://github.com/googleapis/python-pubsub/compare/v2.27.2...v2.27.3) (2025-01-24)
9+
10+
11+
### Bug Fixes
12+
13+
* Stop using api_core default timeouts in publish since they are broken ([#1326](https://github.com/googleapis/python-pubsub/issues/1326)) ([ba2c2ee](https://github.com/googleapis/python-pubsub/commit/ba2c2eef7da89a3c14c14d9b6191cd8738c30341))
14+
815
## [2.27.2](https://github.com/googleapis/python-pubsub/compare/v2.27.1...v2.27.2) (2025-01-06)
916

1017

google/cloud/pubsub_v1/types.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
from google.protobuf import timestamp_pb2
3636

3737
from google.api_core.protobuf_helpers import get_messages
38+
from google.api_core.timeout import ConstantTimeout
3839

3940
from google.pubsub_v1.types import pubsub as pubsub_gapic_types
4041

@@ -191,7 +192,10 @@ 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 ConstantTimeout 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" = ConstantTimeout(60)
195199
(
196200
"Timeout settings for message publishing by the client. It should be "
197201
"compatible with :class:`~.pubsub_v1.types.TimeoutType`."

google/pubsub/gapic_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
__version__ = "2.27.2" # {x-release-please-version}
16+
__version__ = "2.27.3" # {x-release-please-version}

google/pubsub_v1/gapic_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
__version__ = "2.27.2" # {x-release-please-version}
16+
__version__ = "2.27.3" # {x-release-please-version}

samples/generated_samples/snippet_metadata_google.pubsub.v1.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"language": "PYTHON",
1010
"name": "google-cloud-pubsub",
1111
"version": "0.1.0"
12+
"version": "2.27.3"
1213
},
1314
"snippets": [
1415
{

tests/unit/pubsub_v1/publisher/test_publisher_client.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import sys
2020

2121
import grpc
22+
import math
2223

2324
# special case python < 3.8
2425
if sys.version_info.major == 3 and sys.version_info.minor < 8:
@@ -35,6 +36,7 @@
3536
from google.api_core import gapic_v1
3637
from google.api_core import retry as retries
3738
from google.api_core.gapic_v1.client_info import METRICS_METADATA_KEY
39+
from google.api_core.timeout import ConstantTimeout
3840

3941
from google.cloud.pubsub_v1 import publisher
4042
from google.cloud.pubsub_v1 import types
@@ -652,6 +654,8 @@ def test_publish_new_batch_needed(creds):
652654
future = client.publish(topic, b"foo", bar=b"baz")
653655
assert future is mock.sentinel.future
654656

657+
call_args = batch_class.call_args
658+
655659
# Check the mocks.
656660
batch_class.assert_called_once_with(
657661
client=mock.ANY,
@@ -660,8 +664,12 @@ def test_publish_new_batch_needed(creds):
660664
batch_done_callback=None,
661665
commit_when_full=True,
662666
commit_retry=gapic_v1.method.DEFAULT,
663-
commit_timeout=gapic_v1.method.DEFAULT,
667+
commit_timeout=mock.ANY,
664668
)
669+
commit_timeout_arg = call_args[1]["commit_timeout"]
670+
assert isinstance(commit_timeout_arg, ConstantTimeout)
671+
assert math.isclose(commit_timeout_arg._timeout, 60) is True
672+
665673
message_pb = gapic_types.PubsubMessage(data=b"foo", attributes={"bar": "baz"})
666674
wrapper = PublishMessageWrapper(message=message_pb)
667675
batch1.publish.assert_called_once_with(wrapper)

0 commit comments

Comments
 (0)