File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -151,12 +151,19 @@ def _take_batch(self, min_records):
151151 self ._buffer .clear ()
152152 return result
153153
154+
154155 def _send_batch (self , batch ):
155156 for body , callback_args in partition_batch (batch , self .max_batch_size_bytes ):
156157 self ._send (body , callback_args )
157158
158- self .target_messages_per_batch = min (self .max_messages_per_batch ,
159- 0.8 * (self .max_batch_size_bytes / self .moving_average_bytes_per_record ()))
159+ try :
160+ moving_average = self .moving_average_bytes_per_record ()
161+ self .target_messages_per_batch = \
162+ min (self .max_messages_per_batch ,
163+ 0.8 * (self .max_batch_size_bytes / moving_average ))
164+ except ZeroDivisionError :
165+ # Handle the case where there are no records
166+ pass
160167
161168
162169 def _stitch_request (self , body ):
You can’t perform that action at this time.
0 commit comments