File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed
Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -112,7 +112,7 @@ def moving_average_bytes_per_record(self):
112112 num_records += stats .num_records
113113 num_bytes += stats .num_bytes
114114
115- return num_bytes // num_records
115+ return num_bytes // num_records if num_records else None
116116
117117 def push (self , message , callback_arg = None ):
118118 """message should be a dict recognized by the Stitch Import API.
@@ -155,9 +155,12 @@ def _send_batch(self, batch):
155155 for body , callback_args in partition_batch (batch , self .max_batch_size_bytes ):
156156 self ._send (body , callback_args )
157157
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 ()))
160-
158+ if self .moving_average_bytes_per_record ():
159+ self .target_messages_per_batch = \
160+ min (self .max_messages_per_batch ,
161+ 0.8 * (self .max_batch_size_bytes / self .moving_average_bytes_per_record ()))
162+ else :
163+ self .target_messages_per_batch = self .max_messages_per_batch
161164
162165 def _stitch_request (self , body ):
163166 headers = {'Authorization' : 'Bearer {}' .format (self .token ),
You can’t perform that action at this time.
0 commit comments