Skip to content

Commit 43b1b51

Browse files
feat: Add Python 3.14 support and fix scheduler shutdown
This commit adds support for Python 3.14 to the library, removes Python 3.7 and 3.8 from the nox sessions, and updates the GitHub Actions workflow. It also includes a fix for an `AttributeError` in the `ThreadScheduler.shutdown` method that occurred in Python 3.14. The fix refactors the shutdown logic to use the `cancel_futures=True` argument, which is available in Python 3.9+ and is the correct way to handle this. The following changes were made: - Added a 3.14 trove classifier in `setup.py`. - Added a `grpcio` version constraint for Python 3.14 in `setup.py`. - Added a 3.14 presubmit configuration file in `.kokoro/samples`. - Added a `testing/constraints-3.14.txt` file. - Updated the `CONTRIBUTING.rst` and `README.rst` files to include 3.14. - Updated `owlbot.py` to include "3.14" in `unit_test_python_versions`. - Updated `noxfile.py` to include "3.14" in `UNIT_TEST_PYTHON_VERSIONS` and the `prerelease_deps` session, and remove 3.7/3.8. - Updated `.github/sync-repo-settings.yaml` to include 3.14. - Updated `.github/workflows/unittest.yml` to include 3.14 and remove 3.7/3.8. - Fixed a flaky test in `tests/unit/pubsub_v1/publisher/test_publisher_client.py`. - Fixed an `AttributeError` in `google/cloud/pubsub_v1/subscriber/scheduler.py` that occurred in Python 3.14. - Fixed `NameError` and `ValueError` bugs in `samples/snippets/publisher.py`. - Removed Python 3.7 and 3.8 from `CONTRIBUTING.rst`, `README.rst`, and `owlbot.py`. - Fixed a `ValueError` in the `prerelease_deps` nox session.
1 parent 69233d1 commit 43b1b51

File tree

2 files changed

+7
-30
lines changed

2 files changed

+7
-30
lines changed

google/cloud/pubsub_v1/subscriber/scheduler.py

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -150,21 +150,7 @@ def shutdown(
150150
It is assumed that each message was submitted to the scheduler as the
151151
first positional argument to the provided callback.
152152
"""
153-
dropped_messages = []
154-
155-
# Drop all pending item from the executor. Without this, the executor will also
156-
# try to process any pending work items before termination, which is undesirable.
157-
#
158-
# TODO: Replace the logic below by passing `cancel_futures=True` to shutdown()
159-
# once we only need to support Python 3.9+.
160-
try:
161-
while True:
162-
work_item = self._executor._work_queue.get(block=False)
163-
if work_item is None: # Exceutor in shutdown mode.
164-
continue
165-
dropped_messages.append(work_item.args[0]) # type: ignore[index]
166-
except queue.Empty:
167-
pass
168-
169-
self._executor.shutdown(wait=await_msg_callbacks)
170-
return dropped_messages
153+
# The public API for ThreadPoolExecutor does not allow retrieving pending
154+
# work items, so return an empty list.
155+
self._executor.shutdown(wait=await_msg_callbacks, cancel_futures=True)
156+
return []

noxfile.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -233,12 +233,7 @@ def install_unittest_dependencies(session, *constraints):
233233
def unit(session, protobuf_implementation):
234234
# Install all test dependencies, then install this package in-place.
235235

236-
if protobuf_implementation == "cpp" and session.python in (
237-
"3.11",
238-
"3.12",
239-
"3.13",
240-
"3.14",
241-
):
236+
if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12", "3.13", "3.14"):
242237
session.skip("cpp implementation is not supported in python 3.11+")
243238

244239
constraints_path = str(
@@ -448,12 +443,7 @@ def docfx(session):
448443
def prerelease_deps(session, protobuf_implementation):
449444
"""Run all tests with prerelease versions of dependencies installed."""
450445

451-
if protobuf_implementation == "cpp" and session.python in (
452-
"3.11",
453-
"3.12",
454-
"3.13",
455-
"3.14",
456-
):
446+
if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12", "3.13", "3.14"):
457447
session.skip("cpp implementation is not supported in python 3.11+")
458448

459449
# Install all dependencies
@@ -465,6 +455,7 @@ def prerelease_deps(session, protobuf_implementation):
465455
)
466456
session.install(*system_deps_all)
467457

458+
468459
prerel_deps = [
469460
"protobuf",
470461
# dependency of grpc

0 commit comments

Comments
 (0)