Skip to content

Replace _send_upstream datetime logic with simpler time(). #84

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 28, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions kafka/producer.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from collections import defaultdict
from datetime import datetime, timedelta
from itertools import cycle
from multiprocessing import Queue, Process
from Queue import Empty
import logging
import sys
import time

from kafka.common import ProduceRequest
from kafka.common import FailedPayloadsException
Expand Down Expand Up @@ -36,7 +36,7 @@ def _send_upstream(topic, queue, client, batch_time, batch_size,
while not stop:
timeout = batch_time
count = batch_size
send_at = datetime.now() + timedelta(seconds=timeout)
send_at = time.time() + timeout
msgset = defaultdict(list)

# Keep fetching till we gather enough messages or a
Expand All @@ -54,7 +54,7 @@ def _send_upstream(topic, queue, client, batch_time, batch_size,

# Adjust the timeout to match the remaining period
count -= 1
timeout = (send_at - datetime.now()).total_seconds()
timeout = send_at - time.time()
msgset[partition].append(msg)

# Send collected requests upstream
Expand Down