本文整理汇总了Python中pypy.rlib.rstack.resume_point函数的典型用法代码示例。如果您正苦于以下问题:Python resume_point函数的具体用法?Python resume_point怎么用?Python resume_point使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了resume_point函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _execute
def _execute(self, incoming_frame):
state = self.costate
try:
try:
try:
exc = None
thunk = self.thunk
self.thunk = None
syncstate.switched(incoming_frame)
thunk.call()
resume_point("coroutine__bind", state)
except Exception, e:
exc = e
raise
finally:
# warning! we must reload the 'self' from the costate,
# because after a clone() the 'self' of both copies
# point to the original!
self = state.current
self.finish(exc)
except CoroutineExit:
# ignore a shutdown exception
pass
except Exception, e:
# redirect all unhandled exceptions to the parent
syncstate.push_exception(e)
示例2: execute_frame
def execute_frame(self):
"""Execute this frame. Main entry point to the interpreter."""
from pypy.rlib import rstack
# the following 'assert' is an annotation hint: it hides from
# the annotator all methods that are defined in PyFrame but
# overridden in the FrameClass subclass of PyFrame.
assert isinstance(self, self.space.FrameClass)
executioncontext = self.space.getexecutioncontext()
executioncontext.enter(self)
try:
if not we_are_jitted():
executioncontext.call_trace(self)
# Execution starts just after the last_instr. Initially,
# last_instr is -1. After a generator suspends it points to
# the YIELD_VALUE instruction.
next_instr = self.last_instr + 1
try:
w_exitvalue = self.dispatch(self.pycode, next_instr,
executioncontext)
rstack.resume_point("execute_frame", self, executioncontext,
returns=w_exitvalue)
except Exception:
if not we_are_jitted():
executioncontext.return_trace(self, self.space.w_None)
raise
if not we_are_jitted():
executioncontext.return_trace(self, w_exitvalue)
# on exit, we try to release self.last_exception -- breaks an
# obvious reference cycle, so it helps refcounting implementations
self.last_exception = None
finally:
executioncontext.leave(self)
return w_exitvalue
示例3: execute_frame
def execute_frame(self):
"""Execute this frame. Main entry point to the interpreter."""
from pypy.rlib import rstack
# the following 'assert' is an annotation hint: it hides from
# the annotator all methods that are defined in PyFrame but
# overridden in the FrameClass subclass of PyFrame.
assert isinstance(self, self.space.FrameClass)
executioncontext = self.space.getexecutioncontext()
executioncontext.enter(self)
try:
executioncontext.call_trace(self)
# Execution starts just after the last_instr. Initially,
# last_instr is -1. After a generator suspends it points to
# the YIELD_VALUE instruction.
next_instr = self.last_instr + 1
try:
w_exitvalue = self.dispatch(self.pycode, next_instr, executioncontext)
rstack.resume_point("execute_frame", self, executioncontext, returns=w_exitvalue)
except Exception:
executioncontext.return_trace(self, self.space.w_None)
raise
executioncontext.return_trace(self, w_exitvalue)
# clean up the exception, might be useful for not
# allocating exception objects in some cases
self.last_exception = None
finally:
executioncontext.leave(self)
return w_exitvalue
示例4: handle_bytecode
def handle_bytecode(self, co_code, next_instr, ec):
try:
next_instr = self.dispatch_bytecode(co_code, next_instr, ec)
rstack.resume_point("handle_bytecode", self, co_code, ec,
returns=next_instr)
except OperationError, operr:
next_instr = self.handle_operation_error(ec, operr)
示例5: f
def f(x):
x = x - 1
try:
r = g(x)
rstack.resume_point("rp1", returns=r)
except KeyError:
r = 42
return r - 1
示例6: f
def f(coro, n, x):
if n == 0:
coro.switch()
rstack.resume_point("f_0")
return
f(coro, n-1, 2*x)
rstack.resume_point("f_1", coro, n, x)
output.append(x)
示例7: g
def g(x):
r = y = 0
r += f(x)
try:
y = f(x)
rstack.resume_point("rp0", x, r, y, returns=y)
except ZeroDivisionError:
r += f(x)
return r + y
示例8: h
def h(out):
try:
# g is always raising, good enough to put the resume point
# before, instead of after!
rstack.resume_point('h', out)
g(out)
except KeyError:
return 0
return -1
示例9: switch
def switch(self):
if self.frame is None:
# considered a programming error.
# greenlets and tasklets have different ideas about this.
raise CoroutineDamage
state = self.costate
incoming_frame = state.update(self).switch()
resume_point("coroutine_switch", state, returns=incoming_frame)
syncstate.switched(incoming_frame)
示例10: f
def f(coro, n, x):
if n == 0:
coro.switch()
rstack.resume_point("f_0")
assert rstack.stack_frames_depth() == 9
return
f(coro, n-1, 2*x)
rstack.resume_point("f_1", coro, n, x)
output.append(x)
示例11: switch
def switch(self):
if self.frame is None:
raise RuntimeError
state = self.costate
incoming_frame = state.update(self).switch()
rstack.resume_point("coroutine_switch", self, state, returns=incoming_frame)
left = state.last
left.frame = incoming_frame
left.goodbye()
self.hello()
示例12: w_switch
def w_switch(self):
space = self.space
if self.frame is None:
raise OperationError(space.w_ValueError, space.wrap(
"cannot switch to an unbound Coroutine"))
state = self.costate
self.switch()
rstack.resume_point("w_switch", state, space)
w_ret, state.w_tempval = state.w_tempval, space.w_None
return w_ret
示例13: CALL_METHOD
def CALL_METHOD(f, nargs, *ignored):
# 'nargs' is the argument count excluding the implicit 'self'
w_self = f.peekvalue(nargs)
w_callable = f.peekvalue(nargs + 1)
n = nargs + (w_self is not None)
try:
w_result = f.space.call_valuestack(w_callable, n, f)
rstack.resume_point("CALL_METHOD", f, nargs, returns=w_result)
finally:
f.dropvalues(nargs + 2)
f.pushvalue(w_result)
示例14: dispatch
def dispatch(self, pycode, next_instr, ec):
# For the sequel, force 'next_instr' to be unsigned for performance
next_instr = r_uint(next_instr)
co_code = pycode.co_code
try:
while True:
next_instr = self.handle_bytecode(co_code, next_instr, ec)
rstack.resume_point("dispatch", self, co_code, ec,
returns=next_instr)
except ExitFrame:
return self.popvalue()
示例15: call_function
def call_function(f, oparg, w_star=None, w_starstar=None):
n_arguments = oparg & 0xff
n_keywords = (oparg>>8) & 0xff
keywords = None
if n_keywords:
keywords = f.popstrdictvalues(n_keywords)
arguments = f.popvalues(n_arguments)
args = Arguments(f.space, arguments, keywords, w_star, w_starstar)
w_function = f.popvalue()
w_result = f.space.call_args(w_function, args)
rstack.resume_point("call_function", f, returns=w_result)
f.pushvalue(w_result)