本文整理汇总了Python中cqlengine.query.BatchQuery.add_callback方法的典型用法代码示例。如果您正苦于以下问题:Python BatchQuery.add_callback方法的具体用法?Python BatchQuery.add_callback怎么用?Python BatchQuery.add_callback使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cqlengine.query.BatchQuery
的用法示例。
在下文中一共展示了BatchQuery.add_callback方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_callbacks_properly_execute_callables_and_tuples
# 需要导入模块: from cqlengine.query import BatchQuery [as 别名]
# 或者: from cqlengine.query.BatchQuery import add_callback [as 别名]
def test_callbacks_properly_execute_callables_and_tuples(self):
call_history = []
def my_callback(*args, **kwargs):
call_history.append(args)
# adding on init:
batch = BatchQuery()
batch.add_callback(my_callback)
batch.add_callback(my_callback, 'more', 'args')
batch.execute()
assert len(call_history) == 2
assert [(), ('more', 'args')] == call_history
示例2: test_API_managing_callbacks
# 需要导入模块: from cqlengine.query import BatchQuery [as 别名]
# 或者: from cqlengine.query.BatchQuery import add_callback [as 别名]
def test_API_managing_callbacks(self):
# Callbacks can be added at init and after
def my_callback(*args, **kwargs):
pass
# adding on init:
batch = BatchQuery()
batch.add_callback(my_callback)
batch.add_callback(my_callback, 2, named_arg='value')
batch.add_callback(my_callback, 1, 3)
assert batch._callbacks == [
(my_callback, (), {}),
(my_callback, (2,), {'named_arg':'value'}),
(my_callback, (1, 3), {})
]