class TextLog_usingLogger(TextLog): def __init__(self, settings): self.logger = logging.Logger("unique name", level=logging.INFO) self.logger.addHandler(make_log_from_settings(settings)) # TURNS OUT LOGGERS ARE REALLY SLOW TOO self.queue = threads.Queue("queue for classic logger", max=10000, silent=True) self.thread = Thread( "pushing to classic logger", time_delta_pusher, appender=self.logger.info, queue=self.queue, interval=0.3 ) self.thread.parent.remove_child(self.thread) # LOGGING WILL BE RESPONSIBLE FOR THREAD stop() self.thread.start() def write(self, template, params): # http://docs.python.org/2/library/logging.html# logging.LogRecord self.queue.add({"template": template, "params": params}) def stop(self): with suppress_exception: self.queue.add(Thread.STOP) # BE PATIENT, LET REST OF MESSAGE BE SENT self.thread.join() with suppress_exception: self.queue.close()
class Log_usingLogger(BaseLog): def __init__(self, settings): self.logger = logging.Logger("unique name", level=logging.INFO) self.logger.addHandler(make_log_from_settings(settings)) # TURNS OUT LOGGERS ARE REALLY SLOW TOO self.queue = threads.Queue("log to classic logger", max=10000, silent=True) self.thread = Thread("log to logger", time_delta_pusher, appender=self.logger.info, queue=self.queue, interval=timedelta(seconds=0.3)) self.thread.start() def write(self, template, params): # http://docs.python.org/2/library/logging.html# logging.LogRecord self.queue.add({"template": template, "params": params}) def stop(self): try: if DEBUG_LOGGING: sys.stdout.write("Log_usingLogger sees stop, adding stop to queue\n") self.queue.add(Thread.STOP) # BE PATIENT, LET REST OF MESSAGE BE SENT self.thread.join() if DEBUG_LOGGING: sys.stdout.write("Log_usingLogger done\n") except Exception, e: pass try: self.queue.close() except Exception, f: pass
class TextLog_usingLogger(TextLog): def __init__(self, settings): self.logger = logging.Logger("unique name", level=logging.INFO) self.logger.addHandler(make_log_from_settings(settings)) # TURNS OUT LOGGERS ARE REALLY SLOW TOO self.queue = threads.Queue("log to classic logger", max=10000, silent=True) self.thread = Thread("log to logger", time_delta_pusher, appender=self.logger.info, queue=self.queue, interval=timedelta(seconds=0.3)) self.thread.parent.remove_child(self.thread) # LOGGING WILL BE RESPONSIBLE FOR THREAD stop() self.thread.start() def write(self, template, params): # http://docs.python.org/2/library/logging.html# logging.LogRecord self.queue.add({"template": template, "params": params}) def stop(self): with suppress_exception: if DEBUG_LOGGING: sys.stdout.write("TextLog_usingLogger sees stop, adding stop to queue\n") self.queue.add(Thread.STOP) # BE PATIENT, LET REST OF MESSAGE BE SENT self.thread.join() if DEBUG_LOGGING: sys.stdout.write("TextLog_usingLogger done\n") with suppress_exception: self.queue.close()
def inners(): for t in data.hits.hits: for i in t.inner_hits[literal_field(query_path)].hits.hits: t._inner = i._source for k, e in post_expressions.items(): t[k] = e(t) yield t if more_filter: Thread.join(need_more) for t in more[0].hits.hits: yield t
def inners(): for t in data.hits.hits: for i in t.inner_hits[literal_field(query_path)].hits.hits: t._inner = i._source for k, e in post_expressions.items(): t[k] = e(t) yield t if more_filter: Thread.join(need_more) for t in more[0].hits.hits: yield t