Skip to content

Commit

Permalink
Merge branch 'main' into set-creds-to-transport
Browse files Browse the repository at this point in the history
  • Loading branch information
ohmayr authored Jan 24, 2025
2 parents ec9ddcf + 32d0998 commit e4b5810
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
".": "2.27.2"
".": "2.27.3"
}

7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
[1]: https://pypi.org/project/google-cloud-pubsub/#history


## [2.27.3](https://github.com/googleapis/python-pubsub/compare/v2.27.2...v2.27.3) (2025-01-24)


### Bug Fixes

* 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))

## [2.27.2](https://github.com/googleapis/python-pubsub/compare/v2.27.1...v2.27.2) (2025-01-06)


Expand Down
6 changes: 5 additions & 1 deletion google/cloud/pubsub_v1/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from google.protobuf import timestamp_pb2

from google.api_core.protobuf_helpers import get_messages
from google.api_core.timeout import ConstantTimeout

from google.pubsub_v1.types import pubsub as pubsub_gapic_types

Expand Down Expand Up @@ -191,7 +192,10 @@ class PublisherOptions(NamedTuple):
"an instance of :class:`google.api_core.retry.Retry`."
)

timeout: "OptionalTimeout" = gapic_v1.method.DEFAULT # use api_core default
# Use ConstantTimeout instead of api_core default because the default
# value results in retries with zero deadline.
# Refer https://github.com/googleapis/python-api-core/issues/654
timeout: "OptionalTimeout" = ConstantTimeout(60)
(
"Timeout settings for message publishing by the client. It should be "
"compatible with :class:`~.pubsub_v1.types.TimeoutType`."
Expand Down
2 changes: 1 addition & 1 deletion google/pubsub/gapic_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
__version__ = "2.27.2" # {x-release-please-version}
__version__ = "2.27.3" # {x-release-please-version}
2 changes: 1 addition & 1 deletion google/pubsub_v1/gapic_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
__version__ = "2.27.2" # {x-release-please-version}
__version__ = "2.27.3" # {x-release-please-version}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"language": "PYTHON",
"name": "google-cloud-pubsub",
"version": "0.1.0"
"version": "2.27.3"
},
"snippets": [
{
Expand Down
10 changes: 9 additions & 1 deletion tests/unit/pubsub_v1/publisher/test_publisher_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import sys

import grpc
import math

# special case python < 3.8
if sys.version_info.major == 3 and sys.version_info.minor < 8:
Expand All @@ -35,6 +36,7 @@
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.api_core.timeout import ConstantTimeout

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

call_args = batch_class.call_args

# Check the mocks.
batch_class.assert_called_once_with(
client=mock.ANY,
Expand All @@ -660,8 +664,12 @@ def test_publish_new_batch_needed(creds):
batch_done_callback=None,
commit_when_full=True,
commit_retry=gapic_v1.method.DEFAULT,
commit_timeout=gapic_v1.method.DEFAULT,
commit_timeout=mock.ANY,
)
commit_timeout_arg = call_args[1]["commit_timeout"]
assert isinstance(commit_timeout_arg, ConstantTimeout)
assert math.isclose(commit_timeout_arg._timeout, 60) is True

message_pb = gapic_types.PubsubMessage(data=b"foo", attributes={"bar": "baz"})
wrapper = PublishMessageWrapper(message=message_pb)
batch1.publish.assert_called_once_with(wrapper)
Expand Down

0 comments on commit e4b5810

Please sign in to comment.