本文整理汇总了Python中statemachine.StateMachine.add_persistent_task方法的典型用法代码示例。如果您正苦于以下问题:Python StateMachine.add_persistent_task方法的具体用法?Python StateMachine.add_persistent_task怎么用?Python StateMachine.add_persistent_task使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类statemachine.StateMachine
的用法示例。
在下文中一共展示了StateMachine.add_persistent_task方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: StateMachine
# 需要导入模块: from statemachine import StateMachine [as 别名]
# 或者: from statemachine.StateMachine import add_persistent_task [as 别名]
startstate = MetaRescue
resumed = True
logging.info("Resuming at Metadata Rescue...")
else:
startstate = MetaClone
# STATEMACHINE
sm = StateMachine(0.1, startstate, globals(), locals())
BTRACE_POLL_COUNT = 0
def btrace_poller(smobj):
global BTRACE_POLL_COUNT
if btrace.blkparse is not None and btrace.parser is not None:
lines_read = btrace.parser.read_btrace()
BTRACE_POLL_COUNT += 1
if lines_read > 0:
# unused are marked finished so when ANDed using ddrescuelog
# only definitely unused parts remain finished
btracelog = btrace.parser.write_ddrescuelog(OPTIONS,
'non-tried', 'finished', 0, DEVSIZE)
if ddrescue.VIEWER is not None:
shutil.copyfile(btracelog, ddrescue.ddrlog)
sm.add_persistent_task(btrace_poller)
# EXECUTE
sm.run()
# CLEANUP BEFORE NORMAL EXIT
cleanup()