本文整理汇总了Python中hazelcast.future.Future.result方法的典型用法代码示例。如果您正苦于以下问题:Python Future.result方法的具体用法?Python Future.result怎么用?Python Future.result使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hazelcast.future.Future
的用法示例。
在下文中一共展示了Future.result方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_set_result
# 需要导入模块: from hazelcast.future import Future [as 别名]
# 或者: from hazelcast.future.Future import result [as 别名]
def test_set_result(self):
f = Future()
def set_result():
f.set_result("done")
Thread(target=set_result).start()
self.assertEqual(f.result(), "done")
示例2: test_result_raises_exception_with_traceback
# 需要导入模块: from hazelcast.future import Future [as 别名]
# 或者: from hazelcast.future.Future import result [as 别名]
def test_result_raises_exception_with_traceback(self):
f = Future()
exc_info = None
try:
{}["invalid_key"]
except KeyError as e:
exc_info = sys.exc_info()
f.set_exception(e, sys.exc_info()[2])
try:
f.result()
self.fail("Future.result() should raise exception")
except:
info = sys.exc_info()
self.assertEqual(info[1], exc_info[1])
original_tb = traceback.extract_tb(exc_info[2])
# shift traceback by one to discard the last frame
actual_tb = traceback.extract_tb(info[2])[1:]
self.assertEqual(original_tb, actual_tb)