diff --git a/kafka/producer.py b/kafka/producer.py index f7962da8a..75dcbf696 100644 --- a/kafka/producer.py +++ b/kafka/producer.py @@ -100,7 +100,11 @@ def _send_upstream(self, queue): # Adjust the timeout to match the remaining period count -= 1 - timeout = (send_at - datetime.now()).total_seconds() + dt = (send_at - datetime.now()) + if hasattr(dt,'total_seconds'): + timeout = dt.total_seconds() + else: + timeout = (dt.microseconds + (dt.seconds + dt.days * 24 * 3600) * 10**6) / 10**6 msgset[partition].append(msg) # Send collected requests upstream