diff options
author | Linus Wallgren <linus.wallgren@gmail.com> | 2017-05-18 22:49:20 +0200 |
---|---|---|
committer | Dana Powers <dana.powers@gmail.com> | 2017-06-16 23:26:14 -0700 |
commit | 97261f491d02fb7f72ba30abcfc26240f520a9b4 (patch) | |
tree | f01f4d23df893acb4093c2e330730208e6c5e7f3 /example.py | |
parent | 73d78bc76ade2b42abcdea32095d1df930e21c55 (diff) | |
download | kafka-python-97261f491d02fb7f72ba30abcfc26240f520a9b4.tar.gz |
Describe consumer thread-safety
Diffstat (limited to 'example.py')
-rwxr-xr-x | example.py | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -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) |