当前位置: 首页>>代码示例>>Python>>正文


Python compat.range函数代码示例

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


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

示例1: testPool

    def testPool(self):
        pool = PythonProxyPool()
        runners = [Runner(range(0, 10000), pool) for _ in range(0, 3)]
        for runner in runners:
            runner.start()

        for runner in runners:
            runner.join()

        for runner in runners:
            self.assertTrue(runner.ok)
开发者ID:DawnScience,项目名称:py4j,代码行数:11,代码来源:java_callback_test.py

示例2: testRedirectToQueue

 def testRedirectToQueue(self):
     qout = Queue()
     qerr = Queue()
     self.gateway = JavaGateway.launch_gateway(
         redirect_stdout=qout, redirect_stderr=qerr)
     for i in range(10):
         self.gateway.jvm.System.out.println("Test")
         self.gateway.jvm.System.err.println("Test2")
     sleep()
     for i in range(10):
         self.assertEqual("Test\n", qout.get())
         self.assertEqual("Test2\n", qerr.get())
     self.assertTrue(qout.empty)
     self.assertTrue(qerr.empty)
开发者ID:18600597055,项目名称:hue,代码行数:14,代码来源:java_gateway_test.py

示例3: testRedirectToDeque

 def testRedirectToDeque(self):
     qout = deque()
     qerr = deque()
     self.gateway = JavaGateway.launch_gateway(
         redirect_stdout=qout, redirect_stderr=qerr)
     for i in range(10):
         self.gateway.jvm.System.out.println("Test")
         self.gateway.jvm.System.err.println("Test2")
     sleep()
     for i in range(10):
         self.assertEqual("Test\n", qout.pop())
         self.assertEqual("Test2\n", qerr.pop())
     self.assertEqual(0, len(qout))
     self.assertEqual(0, len(qerr))
开发者ID:18600597055,项目名称:hue,代码行数:14,代码来源:java_gateway_test.py

示例4: testRedirectToFile

    def testRedirectToFile(self):
        (_, outpath) = tempfile.mkstemp(text=True)
        (_, errpath) = tempfile.mkstemp(text=True)

        stdout = open(outpath, "w")
        stderr = open(errpath, "w")

        try:
            self.gateway = JavaGateway.launch_gateway(
                redirect_stdout=stdout, redirect_stderr=stderr)
            for i in range(10):
                self.gateway.jvm.System.out.println("Test")
                self.gateway.jvm.System.err.println("Test2")
            # Should not be necessary
            quiet_close(stdout)
            quiet_close(stderr)

            # Test that the redirect files were written to correctly
            with open(outpath, "r") as stdout:
                lines = stdout.readlines()
                self.assertEqual(10, len(lines))
                self.assertEqual("Test\n", lines[0])

            with open(errpath, "r") as stderr:
                lines = stderr.readlines()
                self.assertEqual(10, len(lines))
                self.assertEqual("Test2\n", lines[0])
        finally:
            os.unlink(outpath)
            os.unlink(errpath)
开发者ID:18600597055,项目名称:hue,代码行数:30,代码来源:java_gateway_test.py

示例5: testMultiProcessJVMAccess

    def testMultiProcessJVMAccess(self):
        workers = [TestJVM1(self.gateway) for _ in range(8)]

        for worker in workers:
            worker.start()

        for worker in workers:
            worker.join()
开发者ID:Isb1009,项目名称:py4j,代码行数:8,代码来源:multithreadtest.py

示例6: testMultiProcessSystemReference

    def testMultiProcessSystemReference(self):
        System = self.gateway.jvm.java.lang.System
        workers = [TestJVM2(System) for _ in range(8)]

        for worker in workers:
            worker.start()

        for worker in workers:
            worker.join()
开发者ID:Isb1009,项目名称:py4j,代码行数:9,代码来源:multithreadtest.py

示例7: testMultiProcessJVMReference

    def testMultiProcessJVMReference(self):
        jvm = self.gateway.jvm
        workers = [TestJVM3(jvm) for _ in range(8)]

        for worker in workers:
            worker.start()

        for worker in workers:
            worker.join()
开发者ID:Isb1009,项目名称:py4j,代码行数:9,代码来源:multithreadtest.py

示例8: testStress

    def testStress(self):
        # Real stress test!
#        runner1 = Runner(xrange(1,10000,2),self.gateway)
#        runner2 = Runner(xrange(1000,1000000,10000), self.gateway)
#        runner3 = Runner(xrange(1000,1000000,10000), self.gateway)
        # Small stress test
        runner1 = Runner(range(1, 10000, 1000), self.gateway)
        runner2 = Runner(range(1000, 1000000, 100000), self.gateway)
        runner3 = Runner(range(1000, 1000000, 100000), self.gateway)
        runner1.start()
        runner2.start()
        runner3.start()
        runner1.join()
        runner2.join()
        runner3.join()
        self.assertTrue(runner1.ok)
        self.assertTrue(runner2.ok)
        self.assertTrue(runner3.ok)
开发者ID:gdw2,项目名称:py4j,代码行数:18,代码来源:java_gateway_test.py

示例9: testRedirectToDeque

 def testRedirectToDeque(self):
     end = os.linesep
     qout = deque()
     qerr = deque()
     self.gateway = JavaGateway.launch_gateway(
         redirect_stdout=qout, redirect_stderr=qerr)
     for i in range(10):
         self.gateway.jvm.System.out.println("Test")
         self.gateway.jvm.System.err.println("Test2")
     sleep()
     for i in range(10):
         self.assertEqual("Test{0}".format(end), qout.pop())
         # Assert IN because some Java/OS outputs some garbage on stderr.
         line = qerr.pop()
         if stderr_is_polluted(line):
             line = qerr.pop()
         self.assertEqual("Test2{0}".format(end), line)
     self.assertEqual(0, len(qout))
     self.assertEqual(0, len(qerr))
开发者ID:bartdag,项目名称:py4j,代码行数:19,代码来源:java_gateway_test.py

示例10: close

    def close(self):
        """Closes all currently opened connections.

        This operation is not thread safe and is only a best effort strategy
        to close active connections.

        All connections are guaranteed to be closed only if no other thread
        is accessing the client and no call is pending.
        """
        size = len(self.deque)
        for _ in range(0, size):
            try:
                connection = deque.pop()
                connection.close()
            except Exception:
                pass
开发者ID:gdw2,项目名称:py4j,代码行数:16,代码来源:java_gateway.py

示例11: testRedirectToFile

    def testRedirectToFile(self):
        end = os.linesep
        (out_handle, outpath) = tempfile.mkstemp(text=True)
        (err_handle, errpath) = tempfile.mkstemp(text=True)

        stdout = open(outpath, "w")
        stderr = open(errpath, "w")

        try:
            self.gateway = JavaGateway.launch_gateway(
                redirect_stdout=stdout, redirect_stderr=stderr)
            for i in range(10):
                self.gateway.jvm.System.out.println("Test")
                self.gateway.jvm.System.err.println("Test2")
            self.gateway.shutdown()
            sleep()
            # Should not be necessary
            quiet_close(stdout)
            quiet_close(stderr)

            # Test that the redirect files were written to correctly
            with open(outpath, "r") as stdout:
                lines = stdout.readlines()
                self.assertEqual(10, len(lines))
                self.assertEqual("Test{0}".format(end), lines[0])

            with open(errpath, "r") as stderr:
                lines = stderr.readlines()
                if not stderr_is_polluted(lines[0]):
                    self.assertEqual(10, len(lines))
                    # XXX Apparently, it's \n by default even on windows...
                    # Go figure
                    self.assertEqual("Test2\n", lines[0])
        finally:
            os.close(out_handle)
            os.close(err_handle)
            os.unlink(outpath)
            os.unlink(errpath)
开发者ID:bartdag,项目名称:py4j,代码行数:38,代码来源:java_gateway_test.py

示例12: disconnect

    def disconnect(self, receiver, sender=None, unique_id=None):
        """Unregisters a receiver for this signal.

        :param receiver: The callable that was registered to receive the
            signal.
        :param unique_id: The unique id of the callable if it was provided.
            Optional.
        :return: True if the receiver was found and disconnected. False
            otherwise.
        :rtype: bool
        """
        full_id = self._get_id(receiver, unique_id, sender)
        disconnected = False

        with self.lock:
            for index in range(len(self.receivers)):
                temp_id = self.receivers[index][0]
                if temp_id == full_id:
                    del self.receivers[index]
                    disconnected = True
                    break

        return disconnected
开发者ID:DiamondLightSource,项目名称:py4j,代码行数:23,代码来源:signals.py

示例13: run

 def run(self):
     for i in range(3):
         print(self.gateway.jvm.java.lang.System.currentTimeMillis())
         sleep()
开发者ID:18600597055,项目名称:hue,代码行数:4,代码来源:multithreadtest.py

示例14: testLargeByteArray

 def testLargeByteArray(self):
     # Regression test for #109, an error when passing large byte arrays.
     self.gateway.jvm.java.nio.ByteBuffer.wrap(bytearray(range(255)))
开发者ID:bartdag,项目名称:py4j,代码行数:3,代码来源:java_gateway_test.py

示例15: testRedirectToNullOtherProcessGroup

 def testRedirectToNullOtherProcessGroup(self):
     self.gateway = JavaGateway.launch_gateway(
         create_new_process_group=True)
     for i in range(4097):  # Hangs if not properly redirected
         self.gateway.jvm.System.out.println("Test")
开发者ID:bartdag,项目名称:py4j,代码行数:5,代码来源:java_gateway_test.py


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