@@ -304,23 +304,21 @@ def channel_factory(
304
304
options = _construct_channel_options (driver_config , endpoint_options )
305
305
logger .debug ("Channel options: {}" .format (options ))
306
306
307
+ kwargs = {}
308
+ compression = getattr (driver_config , "compression" , None )
309
+ if compression is not None :
310
+ kwargs = {"compression" : compression }
311
+
307
312
if driver_config .root_certificates is None and not driver_config .secure_channel :
308
- return channel_provider .insecure_channel (
309
- endpoint , options , compression = getattr (driver_config , "compression" , None )
310
- )
313
+ return channel_provider .insecure_channel (endpoint , options , ** kwargs )
311
314
312
315
root_certificates = driver_config .root_certificates
313
316
if root_certificates is None :
314
317
root_certificates = default_pem .load_default_pem ()
315
318
credentials = grpc .ssl_channel_credentials (
316
319
root_certificates , driver_config .private_key , driver_config .certificate_chain
317
320
)
318
- return channel_provider .secure_channel (
319
- endpoint ,
320
- credentials ,
321
- options ,
322
- compression = getattr (driver_config , "compression" , None ),
323
- )
321
+ return channel_provider .secure_channel (endpoint , credentials , options , ** kwargs )
324
322
325
323
326
324
class EndpointKey (object ):
@@ -434,11 +432,14 @@ def future(
434
432
rpc_state , timeout , metadata = self ._prepare_call (
435
433
stub , rpc_name , request , settings
436
434
)
435
+
436
+ kwargs = {}
437
+ compression = getattr (settings , "compression" , None )
438
+ if compression is not None :
439
+ kwargs = {"compression" : compression }
440
+
437
441
rendezvous , result_future = rpc_state .future (
438
- request ,
439
- timeout ,
440
- metadata ,
441
- compression = getattr (settings , "compression" , None ),
442
+ request , timeout , metadata , ** kwargs
442
443
)
443
444
rendezvous .add_done_callback (
444
445
lambda resp_future : _on_response_callback (
@@ -477,12 +478,12 @@ def __call__(
477
478
stub , rpc_name , request , settings
478
479
)
479
480
try :
480
- response = rpc_state (
481
- request ,
482
- timeout ,
483
- metadata ,
484
- compression = getattr ( settings , "compression" , None ),
485
- )
481
+ kwargs = {}
482
+ compression = getattr ( settings , "compression" , None )
483
+ if compression is not None :
484
+ kwargs = { "compression" : compression }
485
+
486
+ response = rpc_state ( request , timeout , metadata , ** kwargs )
486
487
_log_response (rpc_state , response )
487
488
return (
488
489
response
0 commit comments