Skip to content

Commit 1c21959

Browse files
committed
Fixup throttle_delay calc; reset to None if <= 0
1 parent 70e8608 commit 1c21959

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

kafka/conn.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,12 @@ def throttle_delay(self):
865865
Return the number of milliseconds to wait until connection is no longer throttled.
866866
"""
867867
if self._throttle_time is not None:
868-
return max(0, time.time() - self._throttle_time) * 1000
868+
remaining_ms = (self._throttle_time - time.time()) * 1000
869+
if remaining_ms > 0:
870+
return remaining_ms
871+
else:
872+
self._throttle_time = None
873+
return 0
869874
return 0
870875

871876
def connection_delay(self):

0 commit comments

Comments
 (0)