本文整理匯總了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), {})
]