当前位置: 首页>>代码示例>>Python>>正文


Python Thread.join方法代码示例

本文整理汇总了Python中pyLibrary.thread.threads.Thread.join方法的典型用法代码示例。如果您正苦于以下问题:Python Thread.join方法的具体用法?Python Thread.join怎么用?Python Thread.join使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyLibrary.thread.threads.Thread的用法示例。


在下文中一共展示了Thread.join方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Log_usingLogger

# 需要导入模块: from pyLibrary.thread.threads import Thread [as 别名]
# 或者: from pyLibrary.thread.threads.Thread import join [as 别名]
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
开发者ID:klahnakoski,项目名称:intermittents,代码行数:31,代码来源:log_usingLogger.py

示例2: inners

# 需要导入模块: from pyLibrary.thread.threads import Thread [as 别名]
# 或者: from pyLibrary.thread.threads.Thread import join [as 别名]
 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
开发者ID:klahnakoski,项目名称:MoDataSubmission,代码行数:13,代码来源:deep.py


注:本文中的pyLibrary.thread.threads.Thread.join方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。