2727
2828__CROSS_SYNC_OUTPUT__ = "google.cloud.bigtable.data._sync_autogen._replaceable_channel"
2929
30+
3031@CrossSync .convert_class (sync_name = "_WrappedChannel" , rm_aio = True )
3132class _AsyncWrappedChannel (Channel ):
3233 """
@@ -49,15 +50,12 @@ def stream_unary(self, *args, **kwargs):
4950 def stream_stream (self , * args , ** kwargs ):
5051 return self ._channel .stream_stream (* args , ** kwargs )
5152
52- # grace not supported by sync version
53- @CrossSync .drop
54- async def close (self , grace = None ):
55- return await self ._channel .close (grace = grace )
56-
5753 async def channel_ready (self ):
5854 return await self ._channel .channel_ready ()
5955
60- @CrossSync .convert (sync_name = "__enter__" , replace_symbols = {"__aenter__" : "__enter__" })
56+ @CrossSync .convert (
57+ sync_name = "__enter__" , replace_symbols = {"__aenter__" : "__enter__" }
58+ )
6159 async def __aenter__ (self ):
6260 await self ._channel .__aenter__ ()
6361 return self
@@ -75,7 +73,13 @@ async def wait_for_state_change(self, last_observed_state):
7573 def __getattr__ (self , name ):
7674 return getattr (self ._channel , name )
7775
78- if not CrossSync .is_async :
76+ if CrossSync .is_async :
77+ # grace not supported by sync version
78+ async def close (self , grace = None ):
79+ return await self ._channel .close (grace = grace )
80+
81+ else :
82+ # add required sync methods
7983
8084 def close (self ):
8185 return self ._channel .close ()
@@ -87,9 +91,11 @@ def unsubscribe(self, callback):
8791 return self ._channel .unsubscribe (callback )
8892
8993
90- @CrossSync .convert_class (sync_name = "_ReplaceableChannel" , replace_symbols = {"_AsyncWrappedChannel" : "_WrappedChannel" })
94+ @CrossSync .convert_class (
95+ sync_name = "_ReplaceableChannel" ,
96+ replace_symbols = {"_AsyncWrappedChannel" : "_WrappedChannel" },
97+ )
9198class _AsyncReplaceableChannel (_AsyncWrappedChannel ):
92-
9399 def __init__ (self , channel_fn : Callable [[], Channel ]):
94100 self ._channel_fn = channel_fn
95101 self ._channel = channel_fn ()
@@ -100,13 +106,21 @@ def create_channel(self) -> Channel:
100106 # copy over interceptors
101107 # this is needed because of how gapic attaches the LoggingClientAIOInterceptor
102108 # sync channels add interceptors by wrapping, so this step isn't needed
103- new_channel ._unary_unary_interceptors = self ._channel ._unary_unary_interceptors
104- new_channel ._unary_stream_interceptors = self ._channel ._unary_stream_interceptors
105- new_channel ._stream_unary_interceptors = self ._channel ._stream_unary_interceptors
106- new_channel ._stream_stream_interceptors = self ._channel ._stream_stream_interceptors
109+ new_channel ._unary_unary_interceptors = (
110+ self ._channel ._unary_unary_interceptors
111+ )
112+ new_channel ._unary_stream_interceptors = (
113+ self ._channel ._unary_stream_interceptors
114+ )
115+ new_channel ._stream_unary_interceptors = (
116+ self ._channel ._stream_unary_interceptors
117+ )
118+ new_channel ._stream_stream_interceptors = (
119+ self ._channel ._stream_stream_interceptors
120+ )
107121 return new_channel
108122
109123 def replace_wrapped_channel (self , new_channel : Channel ) -> Channel :
110124 old_channel = self ._channel
111125 self ._channel = new_channel
112- return old_channel
126+ return old_channel
0 commit comments