From d20e1cf0eab090b2f838bfff11b0ae792052aa22 Mon Sep 17 00:00:00 2001 From: Bob Szabo Date: Tue, 26 Nov 2013 13:07:36 -0500 Subject: [PATCH] Updated producer.py to for 2.6 compatibility for total_seconds --- kafka/producer.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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