本文整理汇总了Python中datastore.DataStore.roll_back方法的典型用法代码示例。如果您正苦于以下问题:Python DataStore.roll_back方法的具体用法?Python DataStore.roll_back怎么用?Python DataStore.roll_back使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类datastore.DataStore
的用法示例。
在下文中一共展示了DataStore.roll_back方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handle_put
# 需要导入模块: from datastore import DataStore [as 别名]
# 或者: from datastore.DataStore import roll_back [as 别名]
def handle_put(seq,key, value):
"""Return a tuple containing True and the message
to send back to the client."""
if key not in POROCESSING:
POROCESSING.append(key)
ds = DataStore(key,value)
if ds.put(seq):
POROCESSING.remove(key)
return (True, 'Key [{}] set to [{}]'.format(key, value))
else:
ds.roll_back(seq)
POROCESSING.remove(key)
return (False, 'Could Not be added')
示例2: handle_delete
# 需要导入模块: from datastore import DataStore [as 别名]
# 或者: from datastore.DataStore import roll_back [as 别名]
def handle_delete(seq,key):
"""Return a tuple containing True if the key could be deleted and
the message to send back to the client.
use datastore.get and then before doing doing datastore.delete
"""
ds = DataStore()
if ds.get(key):
POROCESSING.append(key)
if ds.delete(seq,key):
POROCESSING.remove(key)
return (True,'Done')
else:
ds.roll_back(seq)
POROCESSING.remove(key)
return (False,'ERROR: Key [{}] not found and could not be deleted'.format(key))
示例3: handle_abort
# 需要导入模块: from datastore import DataStore [as 别名]
# 或者: from datastore.DataStore import roll_back [as 别名]
def handle_abort(seq):
ds = DataStore()
if ds.roll_back(seq):
return (True,'SEQ Aborted')
return (False,"Error")