Skip to content

Conversation

@musicinmybrain
Copy link
Contributor

This API was removed in Python 3.12.

Fixes Python 3.12 support in grpcio tests.

This is relevant to #33063.

See also #33492.


I have actually only tested this in a form backported to grpc 1.48.4, and I am not able to test the change to bazel/_gevent_test_main.py directly. However, the backported form allows me to build grpc 1.48.4 for Fedora Rawhide with Python 3.12, and I believe the version in this PR to be correct—especially, if CI passes for Python 3.11, I believe this part of the test code will continue to work in Python 3.12.

Copy link
Contributor

@gnossen gnossen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for these 3.12 fixes!

@gnossen
Copy link
Contributor

gnossen commented Jun 21, 2023

Looks like there's a minor import issue:

FAIL: //src/python/grpcio_tests/tests/unit:_channel_args_test.gevent (see /root/.cache/bazel/_bazel_root/954bb7512d44d20015390af6e76121c6/execroot/com_github_grpc_grpc/bazel-out/k8-fastbuild/testlogs/src/python/grpcio_tests/tests/unit/_channel_args_test.gevent/test.log)
INFO: From Testing //src/python/grpcio_tests/tests/unit:_channel_args_test.gevent:
==================== Test output for //src/python/grpcio_tests/tests/unit:_channel_args_test.gevent:
Traceback (most recent call last):
  File "/root/.cache/bazel/_bazel_root/954bb7512d44d20015390af6e76121c6/sandbox/processwrapper-sandbox/2653/execroot/com_github_grpc_grpc/bazel-out/k8-fastbuild/bin/src/python/grpcio_tests/tests/unit/_channel_args_test.gevent.runfiles/com_github_grpc_grpc/src/python/grpcio_tests/tests/unit/_channel_args_test.gevent.main.py", line 95, in <module>
    loader = SingleLoader(target_module)
  File "/root/.cache/bazel/_bazel_root/954bb7512d44d20015390af6e76121c6/sandbox/processwrapper-sandbox/2653/execroot/com_github_grpc_grpc/bazel-out/k8-fastbuild/bin/src/python/grpcio_tests/tests/unit/_channel_args_test.gevent.runfiles/com_github_grpc_grpc/src/python/grpcio_tests/tests/unit/_channel_args_test.gevent.main.py", line 77, in __init__
    module = importlib.util.module_from_spec(spec)
NameError: name 'importlib' is not defined

@musicinmybrain
Copy link
Contributor Author

Looks like there's a minor import issue:

Thanks. I’ve added import importlib to the file.

This API was removed in Python 3.12
(python/cpython#98040).

Fixes Python 3.12 support in grpcio tests.
Do not use importlib find_module API in bazel/_gevent_test_main.py

This API was removed in Python 3.12
(python/cpython#98040).
Copy link
Contributor

@gnossen gnossen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution!

@gnossen gnossen merged commit efc3843 into grpc:master Sep 6, 2023
@copybara-service copybara-service bot added the imported Specifies if the PR has been imported to the internal repository label Sep 7, 2023
@ti-chi-bot ti-chi-bot bot mentioned this pull request Jul 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bloat/none imported Specifies if the PR has been imported to the internal repository lang/Python per-call-memory/neutral per-channel-memory/neutral release notes: no Indicates if PR should not be in release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants