本文整理匯總了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()