Skip to content

Commit

Permalink
Merge branch 'main' into optimisticSub
Browse files Browse the repository at this point in the history
  • Loading branch information
mukund-ananthu committed Jun 17, 2024
2 parents 7279128 + 5094605 commit 1ffaf01
Show file tree
Hide file tree
Showing 16 changed files with 43 additions and 22 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.21.2"
".": "2.21.3"
}

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


## [2.21.3](https://github.com/googleapis/python-pubsub/compare/v2.21.2...v2.21.3) (2024-06-10)


### Bug Fixes

* Race condition where future callbacks invoked before client is in paused state ([#1145](https://github.com/googleapis/python-pubsub/issues/1145)) ([d12bac6](https://github.com/googleapis/python-pubsub/commit/d12bac6d94b337aa8978006600fb00e5b13d741d))
* Suppress warnings caused during pytest runs ([#1189](https://github.com/googleapis/python-pubsub/issues/1189)) ([cd51149](https://github.com/googleapis/python-pubsub/commit/cd51149c9e0d3c59d1c75395c05308e860908bf9))
* Typecheck errors in samples/snippets/subscriber.py ([#1186](https://github.com/googleapis/python-pubsub/issues/1186)) ([3698450](https://github.com/googleapis/python-pubsub/commit/3698450041cb4db0e2957832c24450f674b89c11))

## [2.21.2](https://github.com/googleapis/python-pubsub/compare/v2.21.1...v2.21.2) (2024-05-30)


Expand Down
8 changes: 4 additions & 4 deletions google/cloud/pubsub_v1/publisher/_batch/thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def __init__(
client: "PublisherClient",
topic: str,
settings: "types.BatchSettings",
batch_done_callback: Callable[[bool], Any] = None,
batch_done_callback: Optional[Callable[[bool], Any]] = None,
commit_when_full: bool = True,
commit_retry: "OptionalRetry" = gapic_v1.method.DEFAULT,
commit_timeout: "types.OptionalTimeout" = gapic_v1.method.DEFAULT,
Expand Down Expand Up @@ -282,14 +282,14 @@ def _commit(self) -> None:
# all futures and exit.
self._status = base.BatchStatus.ERROR

for future in self._futures:
future.set_exception(exc)

batch_transport_succeeded = False
if self._batch_done_callback is not None:
# Failed to publish batch.
self._batch_done_callback(batch_transport_succeeded)

for future in self._futures:
future.set_exception(exc)

return

end = time.time()
Expand Down
2 changes: 1 addition & 1 deletion google/cloud/pubsub_v1/publisher/futures.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def cancelled(self) -> bool:
"""
return False

def result(self, timeout: Union[int, float] = None) -> str:
def result(self, timeout: Union[int, float, None] = None) -> str:
"""Return the message ID or raise an exception.
This blocks until the message has been published successfully and
Expand Down
4 changes: 2 additions & 2 deletions google/cloud/pubsub_v1/subscriber/_protocol/helper_threads.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import logging
import queue
import time
from typing import Any, Callable, List, Sequence
from typing import Any, Callable, List, Sequence, Optional
import uuid


Expand All @@ -32,7 +32,7 @@


def _get_many(
queue_: queue.Queue, max_items: int = None, max_latency: float = 0
queue_: queue.Queue, max_items: Optional[int] = None, max_latency: float = 0
) -> List[Any]:
"""Get multiple items from a Queue.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def __init__(
client: "subscriber.Client",
subscription: str,
flow_control: types.FlowControl = types.FlowControl(),
scheduler: ThreadScheduler = None,
scheduler: Optional[ThreadScheduler] = None,
use_legacy_flow_control: bool = False,
await_callbacks_on_shutdown: bool = False,
):
Expand Down
2 changes: 1 addition & 1 deletion google/cloud/pubsub_v1/subscriber/futures.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def cancelled(self) -> bool:
"""
return False

def result(self, timeout: Union[int, float] = None) -> AcknowledgeStatus:
def result(self, timeout: Union[int, float, None] = None) -> AcknowledgeStatus:
"""Return a success code or raise an exception.
This blocks until the operation completes successfully and
Expand Down
2 changes: 1 addition & 1 deletion google/cloud/pubsub_v1/subscriber/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def shutdown(
work_item = self._executor._work_queue.get(block=False)
if work_item is None: # Exceutor in shutdown mode.
continue
dropped_messages.append(work_item.args[0])
dropped_messages.append(work_item.args[0]) # type: ignore[index]
except queue.Empty:
pass

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.21.2" # {x-release-please-version}
__version__ = "2.21.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.21.2" # {x-release-please-version}
__version__ = "2.21.3" # {x-release-please-version}
2 changes: 1 addition & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
ISORT_VERSION = "isort==5.11.0"
LINT_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"]

MYPY_VERSION = "mypy==0.910"
MYPY_VERSION = "mypy==1.10.0"

DEFAULT_PYTHON_VERSION = "3.8"

Expand Down
2 changes: 1 addition & 1 deletion owlbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@
s.replace(
"noxfile.py",
r"LINT_PATHS = \[.*?\]",
'\g<0>\n\nMYPY_VERSION = "mypy==0.910"',
'\g<0>\n\nMYPY_VERSION = "mypy==1.10.0"',
)
s.replace(
"noxfile.py", r'"blacken",', '\g<0>\n "mypy",',
Expand Down
6 changes: 5 additions & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,8 @@ filterwarnings =
# Remove warning once https://github.com/googleapis/gapic-generator-python/issues/1939 is fixed
ignore:get_mtls_endpoint_and_cert_source is deprecated.:DeprecationWarning
# Remove warning once https://github.com/grpc/grpc/issues/35974 is fixed
ignore:unclosed:ResourceWarning
ignore:unclosed:ResourceWarning
# Added to suppress "DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html"
# Remove once the minimum supported version of googleapis-common-protos is 1.62.0
ignore:.*pkg_resources.declare_namespace:DeprecationWarning
ignore:.*pkg_resources is deprecated as an API:DeprecationWarning
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
],
"language": "PYTHON",
"name": "google-cloud-pubsub",
"version": "2.21.2"
"version": "2.21.3"
},
"snippets": [
{
Expand Down
6 changes: 5 additions & 1 deletion samples/snippets/mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,9 @@ strict = True
exclude = noxfile\.py
warn_unused_configs = True

[mypy-avro.*,backoff,flaky]
; Ignore errors caused due to missing library stubs or py.typed marker
; Refer https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-library-stubs-or-py-typed-marker
; Errors ignored instead of adding stubs as a workaround, since this directory contains sample code
; that does not affect the functionality of the client library.
[mypy-avro.*,backoff,flaky,google.cloud.*]
ignore_missing_imports = True
12 changes: 8 additions & 4 deletions samples/snippets/subscriber.py
Original file line number Diff line number Diff line change
Expand Up @@ -599,8 +599,10 @@ def update_subscription_with_dead_letter_policy(
)

with subscriber:
subscription_after_update = subscriber.update_subscription(
request={"subscription": subscription, "update_mask": update_mask}
subscription_after_update: gapic_types.Subscription = (
subscriber.update_subscription(
request={"subscription": subscription, "update_mask": update_mask}
)
)

print(f"After the update: {subscription_after_update}.")
Expand Down Expand Up @@ -644,8 +646,10 @@ def remove_dead_letter_policy(
)

with subscriber:
subscription_after_update = subscriber.update_subscription(
request={"subscription": subscription, "update_mask": update_mask}
subscription_after_update: gapic_types.Subscription = (
subscriber.update_subscription(
request={"subscription": subscription, "update_mask": update_mask}
)
)

print(f"After removing the policy: {subscription_after_update}.")
Expand Down

0 comments on commit 1ffaf01

Please sign in to comment.