From 97261f491d02fb7f72ba30abcfc26240f520a9b4 Mon Sep 17 00:00:00 2001 From: Linus Wallgren Date: Thu, 18 May 2017 22:49:20 +0200 Subject: Describe consumer thread-safety --- example.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'example.py') diff --git a/example.py b/example.py index a1a1e1e..2431ee2 100755 --- a/example.py +++ b/example.py @@ -1,5 +1,6 @@ #!/usr/bin/env python import threading, logging, time +import multiprocessing from kafka import KafkaConsumer, KafkaProducer @@ -16,7 +17,7 @@ class Producer(threading.Thread): time.sleep(1) -class Consumer(threading.Thread): +class Consumer(multiprocessing.Process): daemon = True def run(self): @@ -29,12 +30,12 @@ class Consumer(threading.Thread): def main(): - threads = [ + tasks = [ Producer(), Consumer() ] - for t in threads: + for t in tasks: t.start() time.sleep(10) -- cgit v1.2.1