本文整理汇总了Python中context.Context.add_error_and_throw方法的典型用法代码示例。如果您正苦于以下问题:Python Context.add_error_and_throw方法的具体用法?Python Context.add_error_and_throw怎么用?Python Context.add_error_and_throw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类context.Context
的用法示例。
在下文中一共展示了Context.add_error_and_throw方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_node
# 需要导入模块: from context import Context [as 别名]
# 或者: from context.Context import add_error_and_throw [as 别名]
def add_node(self, prev, worker, gstate, do_hash=True):
if do_hash:
hash = gstate.compute_hash()
if hash is not None:
node = self.statespace.get_node_by_hash(hash)
if node is not None:
return (node, False)
else:
hash = None
uid = str(self.statespace.nodes_count)
node = Node(uid, hash)
logging.debug("New node %s", node.uid)
if prev:
node.prev = prev
self.statespace.add_node(node)
if self.debug_compare_states is not None \
and node.uid in self.debug_compare_states:
if self.debug_captured_states is None:
self.debug_captured_states = []
logging.debug("Capturing %s", node)
self.debug_captured_states.append((gstate.copy(), worker))
if self.statespace.nodes_count > self.max_states:
logging.info("Maximal number of states reached")
if self.debug_compare_states is not None:
self.debug_compare()
raise ErrorFound()
if self.debug_state == uid:
context = Context(self, node, None)
context.add_error_and_throw(
errormsg.StateCaptured(context, uid=uid))
return (node, True)
示例2: add_node
# 需要导入模块: from context import Context [as 别名]
# 或者: from context.Context import add_error_and_throw [as 别名]
def add_node(self, prev, gstate, do_hash=True):
if do_hash:
hash = gstate.compute_hash()
if hash is not None:
node = self.statespace.get_node_by_hash(hash)
if node is not None:
return (node, False)
else:
hash = None
uid = str(self.statespace.nodes_count)
node = Node(uid, hash)
logging.debug("New node %s", node.uid)
if prev:
node.prev = prev
self.statespace.add_node(node)
if self.debug_state == uid:
context = Context(self, node, None)
context.add_error_and_throw(errormsg.StateCaptured(context, uid=uid))
return (node, True)