本文整理汇总了Python中pipeline.Pipeline.processing_loop方法的典型用法代码示例。如果您正苦于以下问题:Python Pipeline.processing_loop方法的具体用法?Python Pipeline.processing_loop怎么用?Python Pipeline.processing_loop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pipeline.Pipeline
的用法示例。
在下文中一共展示了Pipeline.processing_loop方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: App
# 需要导入模块: from pipeline import Pipeline [as 别名]
# 或者: from pipeline.Pipeline import processing_loop [as 别名]
class App(object):
exit_cond = threading.Event()
def __init__(self, configfile):
logger.info('App: starting ...')
self.configfile = configfile
self.config = get_env(self.configfile)
self.pipe = Pipeline(config=self.config)
# let's do init according to our purpose: IN next OUT
self.finput = self.pipe.create_module('file_input')
self.pipe.append(self.finput)
self.output = self.pipe.create_module('file_output')
self.pipe.append(self.output)
self.pipe.start()
self.core_processor = ThreadLoop(loop=self.processing_queue_loop)
self.core_processor.start()
def main(self):
rc = 0
try:
while not self.exit_cond.wait(.1):
time.sleep(.1)
except KeyboardInterrupt as e:
logger.warn('App: KeyboardInterrupt')
rc = -1
self.on_exit()
logger.info('App: exited with {}'.format(rc))
return rc
def processing_queue_loop(self):
try:
self.pipe.processing_loop()
except EOS as e:
logger.info('App: EOS')
self.core_processor.running = False
self.quit()
except Exception as e:
exc_type, exc_value, exc_tb = sys.exc_info()
logger.error('App: Fatal exception in processing_queue_loop')
logger.error('App: ' + ''.join(traceback.format_exception(exc_type, exc_value, exc_tb)))
self.core_processor.running = False
self.quit()
def quit(self):
self.exit_cond.set()
def on_exit(self):
logger.info('App: exit')
self.pipe.stop()
self.core_processor.stop()