Skip to content

Commit 4b20ee6

Browse files
Merge branch 'main' into otel_publish
2 parents 7a3785c + eafc1c8 commit 4b20ee6

File tree

9 files changed

+78
-12
lines changed

9 files changed

+78
-12
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.23.0"
2+
".": "2.23.1"
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.23.1](https://github.com/googleapis/python-pubsub/compare/v2.23.0...v2.23.1) (2024-09-09)
9+
10+
11+
### Bug Fixes
12+
13+
* Replace asserts with None checks for graceful shutdown ([#1244](https://github.com/googleapis/python-pubsub/issues/1244)) ([ced4f52](https://github.com/googleapis/python-pubsub/commit/ced4f527c7f918a87d1b89c2b5da59dbdf00e2c3))
14+
815
## [2.23.0](https://github.com/googleapis/python-pubsub/compare/v2.22.0...v2.23.0) (2024-07-29)
916

1017

google/cloud/pubsub_v1/subscriber/_protocol/streaming_pull_manager.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1104,8 +1104,11 @@ def _on_response(self, response: gapic_types.StreamingPullResponse) -> None:
11041104
)
11051105

11061106
with self._pause_resume_lock:
1107-
assert self._scheduler is not None
1108-
assert self._leaser is not None
1107+
if self._scheduler is None or self._leaser is None:
1108+
_LOGGER.debug(
1109+
f"self._scheduler={self._scheduler} or self._leaser={self._leaser} is None. Stopping further processing."
1110+
)
1111+
return
11091112

11101113
for received_message in received_messages:
11111114
if (

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.23.0" # {x-release-please-version}
16+
__version__ = "2.23.1" # {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.23.0" # {x-release-please-version}
16+
__version__ = "2.23.1" # {x-release-please-version}

samples/generated_samples/snippet_metadata_google.pubsub.v1.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
],
99
"language": "PYTHON",
1010
"name": "google-cloud-pubsub",
11-
"version": "0.1.0"
11+
"version": "2.23.1"
1212
},
1313
"snippets": [
1414
{
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
backoff==2.2.1
22
pytest===7.4.4; python_version == '3.7'
3-
pytest==8.2.2; python_version >= '3.8'
3+
pytest==8.3.2; python_version >= '3.8'
44
mock==5.1.0
55
flaky==3.8.1
66
google-cloud-bigquery==3.25.0
7-
google-cloud-storage==2.17.0
7+
google-cloud-storage==2.18.2

samples/snippets/requirements.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
google-cloud-pubsub==2.22.0
2-
avro==1.11.3
1+
google-cloud-pubsub==2.23.0
2+
avro==1.12.0
33
protobuf===4.24.4; python_version == '3.7'
4-
protobuf==5.27.2; python_version >= '3.8'
5-
avro==1.11.3
4+
protobuf==5.28.0; python_version >= '3.8'
5+
avro==1.12.0

tests/unit/pubsub_v1/subscriber/test_streaming_pull_manager.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1375,6 +1375,62 @@ def test_close_blocking_scheduler_shutdown():
13751375
scheduler.shutdown.assert_called_once_with(await_msg_callbacks=True)
13761376

13771377

1378+
def test__on_response_none_scheduler():
1379+
manager, _, _, _, _, _ = make_running_manager()
1380+
1381+
manager._callback = mock.sentinel.callback
1382+
manager._scheduler = None
1383+
# Set up the messages.
1384+
response = gapic_types.StreamingPullResponse(
1385+
received_messages=[
1386+
gapic_types.ReceivedMessage(
1387+
ack_id="ack1",
1388+
message=gapic_types.PubsubMessage(data=b"foo", message_id="1"),
1389+
),
1390+
gapic_types.ReceivedMessage(
1391+
ack_id="ack2",
1392+
message=gapic_types.PubsubMessage(data=b"bar", message_id="2"),
1393+
delivery_attempt=6,
1394+
),
1395+
]
1396+
)
1397+
1398+
manager._maybe_release_messages = mock.Mock()
1399+
1400+
# adjust message bookkeeping in leaser
1401+
fake_leaser_add(leaser, init_msg_count=0, assumed_msg_size=42)
1402+
manager._on_response(response)
1403+
1404+
manager._maybe_release_messages.assert_not_called
1405+
1406+
1407+
def test__on_response_none_leaser():
1408+
manager, _, _, _, _, _ = make_running_manager()
1409+
1410+
manager._callback = mock.sentinel.callback
1411+
manager._leaser = None
1412+
# Set up the messages.
1413+
response = gapic_types.StreamingPullResponse(
1414+
received_messages=[
1415+
gapic_types.ReceivedMessage(
1416+
ack_id="ack1",
1417+
message=gapic_types.PubsubMessage(data=b"foo", message_id="1"),
1418+
),
1419+
gapic_types.ReceivedMessage(
1420+
ack_id="ack2",
1421+
message=gapic_types.PubsubMessage(data=b"bar", message_id="2"),
1422+
delivery_attempt=6,
1423+
),
1424+
]
1425+
)
1426+
1427+
manager._maybe_release_messages = mock.Mock()
1428+
1429+
manager._on_response(response)
1430+
1431+
manager._maybe_release_messages.assert_not_called
1432+
1433+
13781434
def test_close_nonblocking_scheduler_shutdown():
13791435
manager, _, _, _, _, _ = make_running_manager(await_callbacks_on_shutdown=False)
13801436
scheduler = manager._scheduler

0 commit comments

Comments
 (0)