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

Python util.spinUntil函数代码示例

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

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



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

示例1: testShutdownException

 def testShutdownException(self):
     client = self.client
     f = self.f
     f.protocol.transport.loseConnection()
     client.transport.write("X")
     client.transport.loseWriteConnection()
     spinUntil(lambda :f.protocol.closed, True)
开发者ID:pwarren,项目名称:AGDeviceControl,代码行数:7,代码来源:test_tcp.py


示例2: testKillPty

 def testKillPty(self):
     if self.verbose:
         print "starting processes"
     self.createProcesses(usePTY=1)
     reactor.callLater(1, self.kill, 0)
     reactor.callLater(2, self.kill, 1)
     spinUntil(self.check, 5)
开发者ID:pwarren,项目名称:AGDeviceControl,代码行数:7,代码来源:test_process.py


示例3: testStdio

    def testStdio(self):
        """twisted.internet.stdio test."""
        exe = sys.executable
        scriptPath = util.sibpath(__file__, "process_twisted.py")
        p = Accumulator()
        # As trial chdirs to _trial_temp after startup, this makes any
        # possible relative entries in PYTHONPATH invalid. Attempt to
        # fix that up.  Otherwise process_twisted.py will use the
        # installed Twisted, which isn't really guaranteed to exist at
        # this stage.
        def fixup(l):
            for path in l:
                if os.path.isabs(path):
                    yield path
                else:
                    yield os.path.join(os.path.pardir, path)

        env = {"PYTHONPATH": os.pathsep.join(fixup(sys.path))}
        reactor.spawnProcess(p, exe, [exe, "-u", scriptPath], env=env, path=None, usePTY=self.usePTY)
        p.transport.write("hello, world")
        p.transport.write("abc")
        p.transport.write("123")
        p.transport.closeStdin()
        spinUntil(lambda: p.closed, 10)
        self.assertEquals(
            p.outF.getvalue(),
            "hello, worldabc123",
            "Error message from process_twisted follows:" "\n\n%s\n\n" % p.errF.getvalue(),
        )
开发者ID:pwarren,项目名称:AGDeviceControl,代码行数:29,代码来源:test_process.py


示例4: testClose

 def testClose(self):
     if self.verbose:
         print "starting processes"
     self.createProcesses()
     reactor.callLater(1, self.close, 0)
     reactor.callLater(2, self.close, 1)
     spinUntil(self.check, 5)
开发者ID:pwarren,项目名称:AGDeviceControl,代码行数:7,代码来源:test_process.py


示例5: testClientBind

    def testClientBind(self):
        f = MyServerFactory()
        p = reactor.listenTCP(0, f, interface="127.0.0.1")
        self.ports.append(p)
        
        factory = MyClientFactory()
        reactor.connectTCP("127.0.0.1", p.getHost().port, factory,
                           bindAddress=("127.0.0.1", 0))

        spinUntil(lambda :factory.protocol is not None)
        
        self.assertEquals(factory.protocol.made, 1)

        port = factory.protocol.transport.getHost().port
        f2 = MyClientFactory()
        reactor.connectTCP("127.0.0.1", p.getHost().port, f2,
                           bindAddress=("127.0.0.1", port))


        spinUntil(lambda :f2.failed)
        
        self.assertEquals(f2.failed, 1)
        f2.reason.trap(error.ConnectBindError)
        self.assert_(f2.reason.check(error.ConnectBindError))
        self.assertEquals(f2.stopped, 1)
        
        p.stopListening()
        factory.protocol.transport.loseConnection()

        spinWhile(lambda :p.connected)

        self.assertEquals(factory.stopped, 1)
        self.cleanPorts(*self.ports)
开发者ID:pwarren,项目名称:AGDeviceControl,代码行数:33,代码来源:test_tcp.py


示例6: testLinger

 def testLinger(self):
     # See what happens when all the pipes close before the process
     # actually stops. This test *requires* SIGCHLD catching to work,
     # as there is no other way to find out the process is done.
     exe = sys.executable
     scriptPath = util.sibpath(__file__, "process_linger.py")
     p = Accumulator()
     reactor.spawnProcess(p, exe, [exe, "-u", scriptPath], env=None, path=None, childFDs={1: "r", 2: 2})
     spinUntil(lambda: p.closed, 7)
     self.failUnlessEqual(p.outF.getvalue(), "here is some text\ngoodbye\n")
开发者ID:pwarren,项目名称:AGDeviceControl,代码行数:10,代码来源:test_process.py


示例7: testStdinReader

    def testStdinReader(self):
        pyExe = sys.executable
        scriptPath = util.sibpath(__file__, "process_stdinreader.py")
        p = Accumulator()
        reactor.spawnProcess(p, pyExe, [pyExe, "-u", scriptPath], env=None, path=None)
        p.transport.write("hello, world")
        p.transport.closeStdin()

        spinUntil(lambda: p.closed)
        self.assertEquals(p.errF.getvalue(), "err\nerr\n")
        self.assertEquals(p.outF.getvalue(), "out\nhello, world\nout\n")
开发者ID:pwarren,项目名称:AGDeviceControl,代码行数:11,代码来源:test_process.py


示例8: testOpeningTTY

    def testOpeningTTY(self):
        exe = sys.executable
        scriptPath = util.sibpath(__file__, "process_tty.py")
        p = Accumulator()

        reactor.spawnProcess(p, exe, [exe, "-u", scriptPath], env=None, path=None, usePTY=self.usePTY)
        p.transport.write("hello world!\n")
        spinUntil(lambda: p.closed, 10)
        self.assertEquals(
            p.outF.getvalue(),
            "hello world!\r\nhello world!\r\n",
            "Error message from process_tty follows:\n\n%s\n\n" % p.outF.getvalue(),
        )
开发者ID:pwarren,项目名称:AGDeviceControl,代码行数:13,代码来源:test_process.py


示例9: testNormalTermination

    def testNormalTermination(self):
        if os.path.exists("/bin/true"):
            cmd = "/bin/true"
        elif os.path.exists("/usr/bin/true"):
            cmd = "/usr/bin/true"
        else:
            raise RuntimeError("true not found in /bin or /usr/bin")

        p = TrivialProcessProtocol()
        reactor.spawnProcess(p, cmd, ["true"], env=None, usePTY=self.usePTY)

        spinUntil(lambda: p.finished)
        p.reason.trap(error.ProcessDone)
        self.assertEquals(p.reason.value.exitCode, 0)
        self.assertEquals(p.reason.value.signal, None)
开发者ID:pwarren,项目名称:AGDeviceControl,代码行数:15,代码来源:test_process.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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