Reputation: 3906
Is it possible to check the size of a gRPC message in Python before attempting to send it?
It would be useful when batching together smaller messages/requests client-side to ensure that the message size limit isn't exceeded.
Only current way I know of doing this is to assemble a message, attempt to send it, then retry with several smaller messages if a message size limit error is raised.
Upvotes: 6
Views: 3285
Reputation: 2560
If you're using Protocol Buffers for your messages, I believe the ByteSize()
method would be the right way to determine the serialized size of a message (as commented).
Upvotes: 7