Skip to content
This repository was archived by the owner on Mar 9, 2026. It is now read-only.

Commit a8128c7

Browse files
authored
Revert "fix: get channel target for a gRPC request (#1339)"
This reverts commit 16ea766.
1 parent 06be31a commit a8128c7

File tree

2 files changed

+6
-42
lines changed

2 files changed

+6
-42
lines changed

tests/unit/pubsub_v1/publisher/test_publisher_client.py

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,6 @@
5757
typed_flaky = cast(Callable[[C], C], flaky(max_runs=5, min_passes=1))
5858

5959

60-
# NOTE: This interceptor is required to create an intercept channel.
61-
class _PublisherClientGrpcInterceptor(
62-
grpc.UnaryUnaryClientInterceptor,
63-
):
64-
def intercept_unary_unary(self, continuation, client_call_details, request):
65-
pass
66-
67-
6860
def _assert_retries_equal(retry, retry2):
6961
# Retry instances cannot be directly compared, because their predicates are
7062
# different instances of the same function. We thus manually compare their other
@@ -424,27 +416,17 @@ def init(self, *args, **kwargs):
424416
assert client.transport._ssl_channel_credentials == mock_ssl_creds
425417

426418

427-
def test_init_emulator(monkeypatch, creds):
419+
def test_init_emulator(monkeypatch):
428420
monkeypatch.setenv("PUBSUB_EMULATOR_HOST", "/foo/bar:123")
429421
# NOTE: When the emulator host is set, a custom channel will be used, so
430422
# no credentials (mock ot otherwise) can be passed in.
431-
432-
# TODO(https://github.com/grpc/grpc/issues/38519): Workaround to create an intercept
433-
# channel (for forwards compatibility) with a channel created by the publisher client
434-
# where target is set to the emulator host.
435-
channel = publisher.Client().transport.grpc_channel
436-
interceptor = _PublisherClientGrpcInterceptor()
437-
intercept_channel = grpc.intercept_channel(channel, interceptor)
438-
transport = publisher.Client.get_transport_class("grpc")(
439-
credentials=creds, channel=intercept_channel
440-
)
441-
client = publisher.Client(transport=transport)
423+
client = publisher.Client()
442424

443425
# Establish that a gRPC request would attempt to hit the emulator host.
444426
#
445427
# Sadly, there seems to be no good way to do this without poking at
446428
# the private API of gRPC.
447-
channel = client._transport.publish._thunk("")._channel
429+
channel = client._transport.publish._channel
448430
# Behavior to include dns prefix changed in gRPCv1.63
449431
grpc_major, grpc_minor = [int(part) for part in grpc.__version__.split(".")[0:2]]
450432
if grpc_major > 1 or (grpc_major == 1 and grpc_minor >= 63):

tests/unit/pubsub_v1/subscriber/test_subscriber_client.py

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,6 @@
3636
from google.pubsub_v1.types import PubsubMessage
3737

3838

39-
# NOTE: This interceptor is required to create an intercept channel.
40-
class _SubscriberClientGrpcInterceptor(
41-
grpc.UnaryUnaryClientInterceptor,
42-
):
43-
def intercept_unary_unary(self, continuation, client_call_details, request):
44-
pass
45-
46-
4739
def test_init_default_client_info(creds):
4840
client = subscriber.Client(credentials=creds)
4941

@@ -127,27 +119,17 @@ def init(self, *args, **kwargs):
127119
assert client.transport._ssl_channel_credentials == mock_ssl_creds
128120

129121

130-
def test_init_emulator(monkeypatch, creds):
122+
def test_init_emulator(monkeypatch):
131123
monkeypatch.setenv("PUBSUB_EMULATOR_HOST", "/baz/bacon:123")
132124
# NOTE: When the emulator host is set, a custom channel will be used, so
133125
# no credentials (mock ot otherwise) can be passed in.
134-
135-
# TODO(https://github.com/grpc/grpc/issues/38519): Workaround to create an intercept
136-
# channel (for forwards compatibility) with a channel created by the publisher client
137-
# where target is set to the emulator host.
138-
channel = subscriber.Client().transport.grpc_channel
139-
interceptor = _SubscriberClientGrpcInterceptor()
140-
intercept_channel = grpc.intercept_channel(channel, interceptor)
141-
transport = subscriber.Client.get_transport_class("grpc")(
142-
credentials=creds, channel=intercept_channel
143-
)
144-
client = subscriber.Client(transport=transport)
126+
client = subscriber.Client()
145127

146128
# Establish that a gRPC request would attempt to hit the emulator host.
147129
#
148130
# Sadly, there seems to be no good way to do this without poking at
149131
# the private API of gRPC.
150-
channel = client._transport.pull._thunk("")._channel
132+
channel = client._transport.pull._channel
151133
# Behavior to include dns prefix changed in gRPCv1.63
152134
grpc_major, grpc_minor = [int(part) for part in grpc.__version__.split(".")[0:2]]
153135
if grpc_major > 1 or (grpc_major == 1 and grpc_minor >= 63):

0 commit comments

Comments
 (0)