How to set the compression algorithm at the client side in python

40 views
Skip to first unread message

atomex...@gmail.com

unread,
Jul 13, 2017, 3:58:59 AM7/13/17
to grpc.io

I suppose that since I have my server side written in C++, I could use these methods: ServerBuilder& SetCompressionAlgorithmSupportStatus and ServerBuilder& SetDefaultCompressionAlgorithm. However my client is written in python, and I could only find that grpc.beta.interfaces.GRPCServicerContext and grpc.beta.interfaces.GRPCInvocationContext has a argument called disable_next_response_compression(). So how to set the compression algorithm in python for my client?


atomex...@gmail.com

unread,
Jul 13, 2017, 4:04:50 AM7/13/17
to grpc.io, atomex...@gmail.com
I actually found 1 possible solution, but after I install grpcio and grpcio-tools the folder grpc._cython.cygrpc is still empty. So I suppose we have a new way that is currently not shown in API reference?

import grpc
from grpc._cython.cygrpc import CompressionAlgorithm
from grpc._cython.cygrpc import CompressionLevel

ssl_creds = grpc.ssl_channel_credentials()
chan_ops = [('grpc.default_compression_algorithm', CompressionAlgorithm.gzip),
            ('grpc.grpc.default_compression_level', CompressionLevel.high)] 
chan = grpc.secure_channel("<srv_addr>:<srv_port>", ssl_creds, chan_ops) 
Reply all
Reply to author
Forward
0 new messages