#NEWLINE# def process_sse_events( marathon , config_file , groups , bind_http_https , ssl_certs ) : #NEWLINE# #INDENT# processor = MarathonEventProcessor ( marathon , config_file , groups , bind_http_https , ssl_certs ) #NEWLINE# try : #NEWLINE# #INDENT# events = marathon . get_event_stream ( ) #NEWLINE# for event in events : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# if ( event . data . strip ( ) != '' ) : #NEWLINE# #INDENT# for real_event_data in re . split ( '\\r\\n' , event . data ) : #NEWLINE# #INDENT# data = json . loads ( real_event_data ) #NEWLINE# logger . info ( 'received event of type {0}' . format ( data [ 'eventType' ] ) ) #NEWLINE# processor . handle_event ( data ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# logger . info ( 'skipping empty message' ) #NEWLINE# #UNINDENT# #UNINDENT# except : #NEWLINE# #INDENT# print ( events . data ) #NEWLINE# print ( 'Unexpected error:' , sys . exc_info ( ) [ 0 ] ) #NEWLINE# traceback . print_stack ( ) #NEWLINE# raise #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# finally : #NEWLINE# #INDENT# processor . stop ( )