We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 8e17271 + fde9264 commit de4dfb3Copy full SHA for de4dfb3
1 file changed
stitchclient/client.py
@@ -151,12 +151,19 @@ def _take_batch(self, min_records):
151
self._buffer.clear()
152
return result
153
154
+
155
def _send_batch(self, batch):
156
for body, callback_args in partition_batch(batch, self.max_batch_size_bytes):
157
self._send(body, callback_args)
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()))
+ 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
167
168
169
def _stitch_request(self, body):
0 commit comments