Skip to content
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

Error throw #3

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/test_cons_add_remove.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def new_start(key,value):

print " Adding topic " + topic

fc = FeedConsumer("localhost:9092")
fc = FeedConsumer("localhost:9092", group ='TestGroup')
fc.add_topic(topic,dummy)
fc.start()
fc.add_topic("test1",new_start)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_green_cons.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
logger = logging.getLogger('kafka')
logger.setLevel(logging.INFO)

srv = os.getenv("GOMSG_SRV","localhost:9092")
srv = os.getenv("GOMSG_SRV", "localhost:9092")

def dummy(key, value):
print "[GREEN] %s" % (str(value))
Expand All @@ -24,7 +24,7 @@ def callback_xx(key, value):
print "[GREEN_XX] %s" % (str(value))


fc = GreenFeedConsumer(srv, group ='TestGroup')
fc = GreenFeedConsumer(srv, group ='TestGroup')
print srv
print "listing to topic %s"%(topic)
fc.add_topic(topic, dummy)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_green_cons_add_remove.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def new_start(key,value):

print " Adding topic " + topic

fc = FeedConsumer("localhost:9092")
fc = FeedConsumer("localhost:9092", group ='TestGroup')
fc.add_topic(topic,dummy)
fc.start()
fc.add_topic("test1",new_start)
Expand Down
2 changes: 2 additions & 0 deletions tests/test_partitioned_cons.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ def part2(key,value):
# Or could have given
# fc.add_topic(topic, callback_for_1_and_2, (1,2))

# This will pass only if number of partitions for the topic >=2
fc2 = FeedConsumer(srv, group ='TestGroup')
fc2.add_topic(topic,part1, (1,))

# This will pass only if number of partitions for the topic is = 3.
fc3 = FeedConsumer(srv, group ='TestGroup')
fc3.add_topic(topic,part2, (2,))

Expand Down
2 changes: 1 addition & 1 deletion woof/green_consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import threading, logging, gevent, time

from kafka import KafkaConsumer

from kafka.common import KafkaUnavailableError
log = logging.getLogger("kafka")

class GreenFeedConsumer(threading.Thread):
Expand Down
3 changes: 3 additions & 0 deletions woof/partitioned_producer.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ def _next_partition(self, topic, key):
return self.partitions[topic][self.hash_fn(key) % len(self.partitions[topic])]

def send(self, topic, key, *msg):

if not msg:
raise TypeError("Message field cannot be empty.")
try:
topic = kafka_bytestring(topic)
partition = self._next_partition(topic, key)
Expand Down