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

Python currentVat.get函数代码示例

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

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



在下文中一共展示了get函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: recv

    def recv(self, atom, args):
        from typhon.objects.collections.maps import EMPTY_MAP
        if atom is FROMNOW_1:
            duration = promoteToDouble(args[0])
            p, r = makePromise()
            vat = currentVat.get()
            uv_timer = ruv.alloc_timer(vat.uv_loop)
            # Stash the resolver.
            ruv.stashTimer(uv_timer, (vat, r))
            # repeat of 0 means "don't repeat"
            ruv.timerStart(uv_timer, resolveTimer, int(duration * 1000), 0)
            assert ruv.isActive(uv_timer), "Timer isn't active!?"
            return p

        if atom is TRIAL_1:
            obj = args[0]
            then = time.time()
            obj.call(u"run", [])
            now = time.time()

            # We can't give the value up immediately, due to determinism
            # requirements. Instead, provide it as a promise which will be
            # available on subsequent turns.
            rv = DoubleObject(now - then)
            p, r = makePromise()
            vat = currentVat.get()
            vat.sendOnly(r, RESOLVE_1, [rv], EMPTY_MAP)
            return p

        raise Refused(self, atom, args)
开发者ID:markrwilliams,项目名称:typhon,代码行数:30,代码来源:timers.py


示例2: setContents

    def setContents(self, data):
        sibling = self.temporarySibling(".setContents")

        p, r = makePromise()
        vat = currentVat.get()
        path = sibling.asBytes()
        # Use CREAT | EXCL to cause a failure if the temporary file
        # already exists.
        flags = os.O_WRONLY | os.O_CREAT | os.O_EXCL
        with io:
            f = 0
            try:
                f = ruv.magic_fsOpen(vat, path, flags, 0777)
            except object as err:
                smash(r, StrObject(u"Couldn't open file fount: %s" % err))
            else:
                try:
                    writeLoop(f, data)
                except object as err:
                    ruv.magic_fsClose(vat, f)
                    smash(r, StrObject(u"libuv error: %s" % err))
                else:
                    ruv.magic_fsClose(vat, f)
                    ruv.magic_fsRename(vat, path, self.asBytes())
                    resolve(r, NullObject)
        return p
开发者ID:monte-language,项目名称:typhon,代码行数:26,代码来源:files.py


示例3: whenResolvedOnly

 def whenResolvedOnly(self, o, callback):
     from typhon.objects.collections.maps import EMPTY_MAP
     vat = currentVat.get()
     vat.sendOnly(o, _WHENMORERESOLVED_1,
                  [WhenResolvedReactor(callback, o, None, vat)],
                  EMPTY_MAP)
     return NullObject
开发者ID:monte-language,项目名称:typhon,代码行数:7,代码来源:refs.py


示例4: makeProcess

def makeProcess(executable, args, environment):
    """
    Create a subordinate process on the current node from the given
    executable, arguments, and environment.
    """

    # Third incarnation: libuv-powered and requiring bytes.
    executable = unwrapBytes(executable)
    # This could be an LC, but doing it this way fixes the RPython annotation
    # for the list to be non-None.
    argv = []
    for arg in unwrapList(args):
        s = unwrapBytes(arg)
        assert s is not None, "proven impossible by hand"
        argv.append(s)
    env = {}
    for (k, v) in unwrapMap(environment).items():
        env[unwrapBytes(k)] = unwrapBytes(v)
    packedEnv = [k + '=' + v for (k, v) in env.items()]

    vat = currentVat.get()
    try:
        process = ruv.allocProcess()
        sub = SubProcess(vat, process, argv, env)
        ruv.spawn(vat.uv_loop, process,
                  file=executable, args=argv, env=packedEnv)
        sub.retrievePID()
        return sub
    except ruv.UVError as uve:
        raise userError(u"makeProcess: Couldn't spawn process: %s" %
                        uve.repr().decode("utf-8"))
开发者ID:markrwilliams,项目名称:typhon,代码行数:31,代码来源:processes.py


示例5: makeStdErr

def makeStdErr():
    vat = currentVat.get()
    uv_loop = vat.uv_loop
    tty = ruv.alloc_tty(uv_loop, 2, False)
    # ruv.TTYSetMode(tty, ruv.TTY_MODE_RAW)

    return StreamDrain(ruv.rffi.cast(ruv.stream_tp, tty), vat)
开发者ID:markrwilliams,项目名称:typhon,代码行数:7,代码来源:stdio.py


示例6: run

    def run(self, executable, argv, env, stdinFount=None, stdoutDrain=None,
            stderrDrain=None, stdin=False, stdout=False, stderr=False):
        # Sixth incarnation: Now with streamcaps!

        # Unwrap argv.
        l = []
        for arg in argv:
            bs = unwrapBytes(arg)
            assert bs is not None, "proven impossible"
            l.append(bs)
        argv = l

        # Unwrap and prep environment.
        d = {}
        for (k, v) in env.items():
            d[unwrapBytes(k)] = unwrapBytes(v)
        packedEnv = [k + '=' + v for (k, v) in d.items()]
        env = d

        vat = currentVat.get()

        # Set up the list of streams and attach streamcaps.
        stdinSink = nullSink
        stdoutSource = stderrSource = emptySource
        streams = []
        if stdin:
            stream = ruv.rffi.cast(ruv.stream_tp,
                                   ruv.alloc_pipe(vat.uv_loop))
            streams.append(stream)
            wrapped = ruv.wrapStream(stream, 1)
            stdinSink = StreamSink(wrapped, vat)
        else:
            streams.append(nullptr(ruv.stream_t))
        if stdout:
            stream = ruv.rffi.cast(ruv.stream_tp,
                                   ruv.alloc_pipe(vat.uv_loop))
            streams.append(stream)
            wrapped = ruv.wrapStream(stream, 1)
            stdoutSource = StreamSource(wrapped, vat)
        else:
            streams.append(nullptr(ruv.stream_t))
        if stderr:
            stream = ruv.rffi.cast(ruv.stream_tp,
                                   ruv.alloc_pipe(vat.uv_loop))
            streams.append(stream)
            wrapped = ruv.wrapStream(stream, 1)
            stderrSource = StreamSource(wrapped, vat)
        else:
            streams.append(nullptr(ruv.stream_t))

        try:
            process = ruv.allocProcess()
            sub = SubProcess(vat, process, argv, env, stdin=stdinSink,
                             stdout=stdoutSource, stderr=stderrSource)
            vat.enqueueEvent(SpawnProcessIOEvent(
                vat, sub, process, executable, argv, packedEnv, streams))
            return sub
        except ruv.UVError as uve:
            raise userError(u"makeProcess: Couldn't spawn process: %s" %
                            uve.repr().decode("utf-8"))
开发者ID:monte-language,项目名称:typhon,代码行数:60,代码来源:processes.py


示例7: run

    def run(self, unused):
        from typhon.objects.collections.maps import EMPTY_MAP
        if self.done:
            return

        if self._ref.isResolved():
            if isBroken(self._ref):
                f = self._eb
            else:
                f = self._cb
            try:
                outcome = f.call(u"run", [self._ref])
                if not isBroken(self._ref) and isBroken(outcome):
                    # success arm returned a broken promise
                    outcome = self._eb.call(u"run", [outcome])
                self._resolver.resolve(outcome)
            except UserException as ue:
                from typhon.objects.exceptions import sealException
                if not isBroken(self._ref):
                    # success arm threw
                    try:
                        self._resolver.resolve(self._eb.call(u"run", [UnconnectedRef(currentVat.get(), sealException(ue))]))
                    except UserException as ue2:
                        self._resolver.smash(sealException(ue2))
                else:
                    # failure arm threw
                    self._resolver.smash(sealException(ue))
            self.done = True
        else:
            self.vat.sendOnly(self._ref, _WHENMORERESOLVED_1, [self],
                              EMPTY_MAP)
开发者ID:monte-language,项目名称:typhon,代码行数:31,代码来源:refs.py


示例8: _whenMoreResolved

 def _whenMoreResolved(self, callback):
     from typhon.objects.collections.maps import EMPTY_MAP
     # Welcome to _whenMoreResolved.
     # This method's implementation, in Monte, should be:
     # to _whenMoreResolved(callback): callback<-(self)
     vat = currentVat.get()
     vat.sendOnly(callback, RUN_1, [self], EMPTY_MAP)
     return NullObject
开发者ID:monte-language,项目名称:typhon,代码行数:8,代码来源:refs.py


示例9: makeProxy

def makeProxy(handler, resolutionBox, resolved):
    if not handler.isSettled():
        raise userError(u"Proxy handler not settled")
    vat = currentVat.get()
    if resolved:
        return FarRef(vat, handler, resolutionBox)
    else:
        return RemotePromise(vat, handler, resolutionBox)
开发者ID:monte-language,项目名称:typhon,代码行数:8,代码来源:proxy.py


示例10: whenNear

 def whenNear(self, o, callback):
     from typhon.objects.collections.maps import EMPTY_MAP
     p, r = makePromise()
     vat = currentVat.get()
     vat.sendOnly(o, _WHENMORERESOLVED_1,
                  [WhenNearReactor(callback, o, r, vat)],
                  EMPTY_MAP)
     return p
开发者ID:monte-language,项目名称:typhon,代码行数:8,代码来源:refs.py


示例11: makeStdIn

def makeStdIn():
    vat = currentVat.get()
    uv_loop = vat.uv_loop
    stdinKind = ruv.guess_handle(0)
    if stdinKind == ruv.HANDLE_TTY:
        stdin = ruv.alloc_tty(uv_loop, 0, True)
        return StreamFount(ruv.rffi.cast(ruv.stream_tp, stdin), vat)
    else:
        return FileFount(ruv.alloc_fs(), 0, vat)
开发者ID:dckc,项目名称:typhon,代码行数:9,代码来源:stdio.py


示例12: measureTimeTaken

    def measureTimeTaken(self, f):
        """
        Like m`f<-()`, but returns a promise for a pair
        `[result, timeTaken :Double]` in seconds.
        """

        from typhon.objects.collections.maps import EMPTY_MAP
        vat = currentVat.get()
        return vat.send(TimeMeasurer(f), RUN_0, [], EMPTY_MAP)
开发者ID:monte-language,项目名称:typhon,代码行数:9,代码来源:timers.py


示例13: __init__

    def __init__(self, code, frame, globals):
        self.code = code
        self.env = Environment(frame, globals, self.code.localSize(),
                               promote(self.code.maxDepth),
                               promote(self.code.maxHandlerDepth))

        # For vat checkpointing.
        from typhon.vats import currentVat
        self.vat = currentVat.get()
开发者ID:washort,项目名称:typhon,代码行数:9,代码来源:machine.py


示例14: makeStdOut

def makeStdOut():
    vat = currentVat.get()
    uv_loop = vat.uv_loop
    tty = ruv.alloc_tty(uv_loop, 1, False)
    # XXX works exactly as expected, including disabling most TTY signal
    # generation
    # ruv.TTYSetMode(tty, ruv.TTY_MODE_RAW)

    return StreamDrain(ruv.rffi.cast(ruv.stream_tp, tty), vat)
开发者ID:markrwilliams,项目名称:typhon,代码行数:9,代码来源:stdio.py


示例15: makeReactorStats

def makeReactorStats():
    """
    Compute some information about the reactor.
    """

    # XXX what a hack
    from typhon.vats import currentVat
    loop = currentVat.get().uv_loop
    return LoopStats(loop)
开发者ID:dckc,项目名称:typhon,代码行数:9,代码来源:runtime.py


示例16: stdout

 def stdout(self):
     vat = currentVat.get()
     uv_loop = vat.uv_loop
     kind = ruv.guess_handle(1)
     if kind == ruv.HANDLE_TTY:
         stdout = ruv.alloc_tty(uv_loop, 1, False)
         stream = ruv.wrapStream(ruv.rffi.cast(ruv.stream_tp, stdout), 1)
         return TTYSink(stdout, stream, vat)
     else:
         return FileSink(1, vat)
开发者ID:monte-language,项目名称:typhon,代码行数:10,代码来源:stdio.py


示例17: fromNow

 def fromNow(self, duration):
     p, r = makePromise()
     vat = currentVat.get()
     uv_timer = ruv.alloc_timer(vat.uv_loop)
     now = ruv.now(vat.uv_loop)
     # Stash the resolver.
     ruv.stashTimer(uv_timer, (vat, (r, now)))
     # repeat of 0 means "don't repeat"
     ruv.timerStart(uv_timer, resolveTimer, int(duration * 1000), 0)
     return p
开发者ID:dckc,项目名称:typhon,代码行数:10,代码来源:timers.py


示例18: rename

    def rename(self, dest):
        p, r = makePromise()
        vat = currentVat.get()
        uv_loop = vat.uv_loop
        fs = ruv.alloc_fs()

        src = self.asBytes()
        ruv.stashFS(fs, (vat, r))
        ruv.fsRename(uv_loop, fs, src, dest, renameCB)
        return p
开发者ID:dckc,项目名称:typhon,代码行数:10,代码来源:files.py


示例19: stderr

 def stderr(self):
     vat = currentVat.get()
     uv_loop = vat.uv_loop
     kind = ruv.guess_handle(2)
     if kind == ruv.HANDLE_TTY:
         stderr = ruv.alloc_tty(uv_loop, 2, False)
         stream = ruv.wrapStream(ruv.rffi.cast(ruv.stream_tp, stderr), 1)
         return StreamSink(stream, vat)
     else:
         return FileSink(ruv.alloc_fs(), 2, vat)
开发者ID:dckc,项目名称:typhon,代码行数:10,代码来源:stdio.py


示例20: makeStdErr

def makeStdErr():
    vat = currentVat.get()
    uv_loop = vat.uv_loop
    stderrKind = ruv.guess_handle(2)
    if stderrKind == ruv.HANDLE_TTY:
        tty = ruv.alloc_tty(uv_loop, 2, False)
        # ruv.TTYSetMode(tty, ruv.TTY_MODE_RAW)
        return StreamDrain(ruv.rffi.cast(ruv.stream_tp, tty), vat)
    else:
        return FileDrain(ruv.alloc_fs(), 2, vat)
开发者ID:dckc,项目名称:typhon,代码行数:10,代码来源:stdio.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python typing.cast函数代码示例发布时间:2022-05-27
下一篇:
Python refs.resolution函数代码示例发布时间: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