@@ -77,7 +77,7 @@ def _maybe_remove_from_inflight_batches(self, batch):
77
77
queue .pop ()
78
78
heapq .heapify (queue )
79
79
80
- def _get_expired_inflight_batches (self ):
80
+ def _get_expired_inflight_batches (self , now = None ):
81
81
"""Get the in-flight batches that has reached delivery timeout."""
82
82
expired_batches = []
83
83
to_remove = []
@@ -174,7 +174,7 @@ def run_once(self):
174
174
def _send_producer_data (self , now = None ):
175
175
now = time .time () if now is None else now
176
176
# get the list of partitions with data ready to send
177
- result = self ._accumulator .ready (self ._metadata )
177
+ result = self ._accumulator .ready (self ._metadata , now = now )
178
178
ready_nodes , next_ready_check_delay , unknown_leaders_exist = result
179
179
180
180
# if there are any partitions whose leaders are not known yet, force
@@ -195,7 +195,7 @@ def _send_producer_data(self, now=None):
195
195
196
196
# create produce requests
197
197
batches_by_node = self ._accumulator .drain (
198
- self ._metadata , ready_nodes , self .config ['max_request_size' ])
198
+ self ._metadata , ready_nodes , self .config ['max_request_size' ], now = now )
199
199
200
200
for batch_list in six .itervalues (batches_by_node ):
201
201
for batch in batch_list :
@@ -209,8 +209,9 @@ def _send_producer_data(self, now=None):
209
209
for batch in batch_list :
210
210
self ._accumulator .muted .add (batch .topic_partition )
211
211
212
- expired_batches = self ._accumulator .expired_batches ()
213
- expired_batches .extend (self ._get_expired_inflight_batches ())
212
+ self ._accumulator .reset_next_batch_expiry_time ()
213
+ expired_batches = self ._accumulator .expired_batches (now = now )
214
+ expired_batches .extend (self ._get_expired_inflight_batches (now = now ))
214
215
215
216
if expired_batches :
216
217
log .debug ("%s: Expired %s batches in accumulator" , str (self ), len (expired_batches ))
0 commit comments