 """<STR_LIT>""" <EOL> from kafka . client import KafkaClient <EOL> from kafka . consumer import SimpleConsumer <EOL> import os <EOL> import platform <EOL> if platform . system ( ) == '<STR_LIT>' : <EOL> import win32api <EOL> else : <EOL> import signal <EOL> import thread <EOL> import traceback <EOL> kafkaHost = '<STR_LIT>' <EOL> kafkaTopic = '<STR_LIT>' <EOL> kafkaGroup = '<STR_LIT>' <EOL> kafka = None <EOL> producer = None <EOL> consumer = None <EOL> def onexit ( ) : <EOL> global kafka , consumer , producer <EOL> if consumer : <EOL> consumer . commit ( ) <EOL> consumer . stop ( ) <EOL> consumer = None <EOL> if producer : <EOL> producer . stop ( ) <EOL> producer = None <EOL> if kafka : <EOL> kafka . close ( ) <EOL> kafka = None <EOL> print ( '<STR_LIT>' . format ( os . getpid ( ) ) ) <EOL> def handler ( sig , hook = thread . interrupt_main ) : <EOL> global kafka , consumer , producer <EOL> if consumer : <EOL> consumer . commit ( ) <EOL> consumer . stop ( ) <EOL> consumer = None <EOL> if producer : <EOL> producer . stop ( ) <EOL> producer = None <EOL> if kafka : <EOL> kafka . close ( ) <EOL> kafka = None <EOL> print ( '<STR_LIT>' . format ( os . getpid ( ) ) ) <EOL> exit ( <NUM_LIT:1> ) <EOL> def server ( ) : <EOL> global kafka , producer , consumer <EOL> if platform . system ( ) == '<STR_LIT>' : <EOL> win32api . SetConsoleCtrlHandler ( handler , <NUM_LIT:1> ) <EOL> else : <EOL> signal . signal ( signal . SIGINT , onexit ) <EOL> try : <EOL> kafka = KafkaClient ( kafkaHost , timeout = None ) <EOL> consumer = SimpleConsumer ( kafka , kafkaGroup , kafkaTopic , partitions = [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> ] ) <EOL> for message in consumer : 
 print ( message ) 
 """<STR_LIT>""" <EOL> from kafka . client import KafkaClient <EOL> from kafka . consumer import SimpleConsumer <EOL> import os <EOL> import platform <EOL> if platform . system ( ) == '<STR_LIT>' : <EOL> import win32api <EOL> else : <EOL> import signal <EOL> import thread <EOL> import traceback <EOL> kafkaHost = '<STR_LIT>' <EOL> kafkaTopic = '<STR_LIT>' <EOL> kafkaGroup = '<STR_LIT>' <EOL> kafka = None <EOL> producer = None <EOL> consumer = None <EOL> def onexit ( ) : <EOL> global kafka , consumer , producer <EOL> if consumer : <EOL> consumer . commit ( ) <EOL> consumer . stop ( ) <EOL> consumer = None <EOL> if producer : <EOL> producer . stop ( ) <EOL> producer = None <EOL> if kafka : <EOL> kafka . close ( ) <EOL> kafka = None <EOL> print ( '<STR_LIT>' . format ( os . getpid ( ) ) ) <EOL> def handler ( sig , hook = thread . interrupt_main ) : <EOL> global kafka , consumer , producer <EOL> if consumer : <EOL> consumer . commit ( ) <EOL> consumer . stop ( ) <EOL> consumer = None <EOL> if producer : <EOL> producer . stop ( ) <EOL> producer = None <EOL> if kafka : <EOL> kafka . close ( ) <EOL> kafka = None <EOL> print ( '<STR_LIT>' . format ( os . getpid ( ) ) ) <EOL> exit ( <NUM_LIT:1> ) <EOL> def server ( ) : <EOL> global kafka , producer , consumer <EOL> if platform . system ( ) == '<STR_LIT>' : <EOL> win32api . SetConsoleCtrlHandler ( handler , <NUM_LIT:1> ) <EOL> else : <EOL> signal . signal ( signal . SIGINT , onexit ) <EOL> try : <EOL> kafka = KafkaClient ( kafkaHost , timeout = None ) <EOL> consumer = SimpleConsumer ( kafka , kafkaGroup , kafkaTopic , partitions = [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> ] ) <EOL> for message in consumer : <EOL> print ( message ) <EOL> except Exception as e : <EOL> print ( '<STR_LIT>' . format ( e ) ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( traceback . format_exc ( ) ) <EOL> except KeyboardInterrupt : <EOL> onexit ( ) <EOL> finally : <EOL> onexit ( ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> while <NUM_LIT:1> : <EOL> server ( ) </s>
