def _run(self): total_searched_streams = set() while True: try: event_batch = self.queue.get(False) for event in event_batch.events: revised_event = event.copy() if event.get('timestamp') is not None: revised_event['timestamp'] = \ datetime.fromtimestamp(event['timestamp']/1000.0, tzlocal()) if event.get('ingestionTime') is not None: revised_event['ingestionTime'] = \ datetime.fromtimestamp( event['ingestionTime']/1000.0, tzlocal()) print_stdout(self.output_format.format(**revised_event)) if event_batch.searched_log_streams: for searched_log_stream in event_batch.searched_log_streams: total_searched_streams.add(searched_log_stream.get('logStreamName')) print_stderr("Searching for more data...") except Queue.Empty: if self.stop_flag.is_set(): print_stderr('{0} log streams searched in log group {1}:'.format(len(total_searched_streams), event_batch.log_group_name)) print_stderr(', '.join(sorted(total_searched_streams))) logger.debug('Renderer is leaving...') break else: self.stop_flag.wait(0.1)
def _run(self): while True: try: event_batch = self.queue.get(False) for event in event_batch.events: revised_event = event.copy() if event.get('timestamp') is not None: revised_event['timestamp'] = \ datetime.fromtimestamp(event['timestamp']/1000.0, tzlocal()) if event.get('ingestionTime') is not None: revised_event['ingestionTime'] = \ datetime.fromtimestamp( event['ingestionTime']/1000.0, tzlocal()) print_stdout(self.output_format.format(**revised_event)) except Queue.Empty: if self.stop_flag.is_set(): logger.debug('Renderer is leaving...') break else: self.stop_flag.wait(0.1)