• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python rstack.resume_point函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pypy.rlib.rstack.resume_point函数的典型用法代码示例。如果您正苦于以下问题:Python resume_point函数的具体用法?Python resume_point怎么用?Python resume_point使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了resume_point函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
开发者ID:AishwaryaKM,项目名称:python-tutorial,代码行数:26,代码来源:rcoroutine.py


示例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
开发者ID:enyst,项目名称:plexnet,代码行数:33,代码来源:pyframe.py


示例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
开发者ID:alkorzt,项目名称:pypy,代码行数:29,代码来源:pyframe.py


示例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)
开发者ID:antoine1fr,项目名称:pygirl,代码行数:7,代码来源:pyopcode.py


示例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
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:8,代码来源:test_resume_point.py


示例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)
开发者ID:antoine1fr,项目名称:pygirl,代码行数:8,代码来源:test_coroutine_reconstruction.py


示例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
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:9,代码来源:test_resume_point.py


示例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
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:9,代码来源:test_resume_point.py


示例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)
开发者ID:AishwaryaKM,项目名称:python-tutorial,代码行数:9,代码来源:rcoroutine.py


示例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)
开发者ID:alkorzt,项目名称:pypy,代码行数:9,代码来源:test_coroutine_reconstruction.py


示例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()
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:10,代码来源:test_resume_point.py


示例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
开发者ID:enyst,项目名称:plexnet,代码行数:10,代码来源:interp_coroutine.py


示例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)
开发者ID:AishwaryaKM,项目名称:python-tutorial,代码行数:11,代码来源:callmethod.py


示例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()
开发者ID:antoine1fr,项目名称:pygirl,代码行数:12,代码来源:pyopcode.py


示例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)
开发者ID:antoine1fr,项目名称:pygirl,代码行数:12,代码来源:pyopcode.py


示例16: CALL_FUNCTION

 def CALL_FUNCTION(f, oparg, *ignored):
     # XXX start of hack for performance
     if (oparg >> 8) & 0xff == 0:
         # Only positional arguments
         nargs = oparg & 0xff
         w_function = f.peekvalue(nargs)
         try:
             w_result = f.space.call_valuestack(w_function, nargs, f)
             rstack.resume_point("CALL_FUNCTION", f, nargs, returns=w_result)
         finally:
             f.dropvalues(nargs + 1)
         f.pushvalue(w_result)
     # XXX end of hack for performance
     else:
         # general case
         f.call_function(oparg)
开发者ID:antoine1fr,项目名称:pygirl,代码行数:16,代码来源:pyopcode.py


示例17: 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 = {}
         for i in range(n_keywords):
             w_value = f.valuestack.pop()
             w_key   = f.valuestack.pop()
             key = f.space.str_w(w_key)
             keywords[key] = w_value
     arguments = [None] * n_arguments
     for i in range(n_arguments - 1, -1, -1):
         arguments[i] = f.valuestack.pop()
     args = Arguments(f.space, arguments, keywords, w_star, w_starstar)
     w_function  = f.valuestack.pop()
     w_result = f.space.call_args(w_function, args)
     rstack.resume_point("call_function", f, returns=w_result)
     f.valuestack.push(w_result)
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:19,代码来源:test_resume_point.py


示例18: execute_frame

 def execute_frame(self):
     """Execute this frame.  Main entry point to the interpreter."""
     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
         w_exitvalue = self.dispatch(self.pycode, next_instr,
                                     executioncontext)
         rstack.resume_point("execute_frame", self, executioncontext, returns=w_exitvalue)
         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
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:20,代码来源:pyframe.py


示例19: dispatch_bytecode

    def dispatch_bytecode(self, co_code, next_instr, ec):
        space = self.space
        while True:
            self.last_instr = intmask(next_instr)
            if not we_are_jitted():
                ec.bytecode_trace(self)
                next_instr = r_uint(self.last_instr)
            opcode = ord(co_code[next_instr])
            next_instr += 1
            if space.config.objspace.logbytecodes:
                space.bytecodecounts[opcode] = space.bytecodecounts.get(opcode, 0) + 1

            if opcode >= HAVE_ARGUMENT:
                lo = ord(co_code[next_instr])
                hi = ord(co_code[next_instr+1])
                next_instr += 2
                oparg = (hi << 8) | lo
            else:
                oparg = 0
            hint(opcode, concrete=True)
            hint(oparg, concrete=True)

            while opcode == opcodedesc.EXTENDED_ARG.index:
                opcode = ord(co_code[next_instr])
                if opcode < HAVE_ARGUMENT:
                    raise BytecodeCorruption
                lo = ord(co_code[next_instr+1])
                hi = ord(co_code[next_instr+2])
                next_instr += 3
                oparg = (oparg << 16) | (hi << 8) | lo
                hint(opcode, concrete=True)
                hint(oparg, concrete=True)

            if opcode == opcodedesc.RETURN_VALUE.index:
                w_returnvalue = self.popvalue()
                block = self.unrollstack(SReturnValue.kind)
                if block is None:
                    self.pushvalue(w_returnvalue)   # XXX ping pong
                    raise Return
                else:
                    unroller = SReturnValue(w_returnvalue)
                    next_instr = block.handle(self, unroller)
                    return next_instr    # now inside a 'finally' block

            if opcode == opcodedesc.YIELD_VALUE.index:
                #self.last_instr = intmask(next_instr - 1) XXX clean up!
                raise Yield

            if opcode == opcodedesc.END_FINALLY.index:
                unroller = self.end_finally()
                if isinstance(unroller, SuspendedUnroller):
                    # go on unrolling the stack
                    block = self.unrollstack(unroller.kind)
                    if block is None:
                        w_result = unroller.nomoreblocks()
                        self.pushvalue(w_result)
                        raise Return
                    else:
                        next_instr = block.handle(self, unroller)
                return next_instr

            if we_are_translated():
                for opdesc in unrolling_opcode_descs:
                    # static checks to skip this whole case if necessary
                    if not opdesc.is_enabled(space):
                        continue
                    if not hasattr(pyframe.PyFrame, opdesc.methodname):
                        continue   # e.g. for JUMP_FORWARD, implemented above

                    if opcode == opdesc.index:
                        # dispatch to the opcode method
                        meth = getattr(self, opdesc.methodname)
                        res = meth(oparg, next_instr)
                        if opdesc.index == opcodedesc.CALL_FUNCTION.index:
                            rstack.resume_point("dispatch_call", self, co_code, next_instr, ec)
                        # !! warning, for the annotator the next line is not
                        # comparing an int and None - you can't do that.
                        # Instead, it's constant-folded to either True or False
                        if res is not None:
                            next_instr = res
                        break
                else:
                    self.MISSING_OPCODE(oparg, next_instr)

            else:  # when we are not translated, a list lookup is much faster
                methodname = opcode_method_names[opcode]
                res = getattr(self, methodname)(oparg, next_instr)
                if res is not None:
                    next_instr = res

            if we_are_jitted():
                return next_instr
开发者ID:antoine1fr,项目名称:pygirl,代码行数:92,代码来源:pyopcode.py


示例20: fn

 def fn(x):
     rstack.resume_point('hello world', x)
     return x
开发者ID:AishwaryaKM,项目名称:python-tutorial,代码行数:3,代码来源:operations.py



注:本文中的pypy.rlib.rstack.resume_point函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python rstring.StringBuilder类代码示例发布时间:2022-05-27
下一篇:
Python rsre_re.match函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap