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

Python java_gateway_test.sleep函数代码示例

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

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



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

示例1: start_example_app_process3

def start_example_app_process3():
    # XXX DO NOT FORGET TO KILL THE PROCESS IF THE TEST DOES NOT SUCCEED
    p = Process(target=start_example_server3)
    p.start()
    sleep()
    test_gateway_connection()
    return p
开发者ID:DawnScience,项目名称:py4j,代码行数:7,代码来源:java_callback_test.py


示例2: testProxyReturnerFloatErrorTypeConversion

 def testProxyReturnerFloatErrorTypeConversion(self):
     sleep()
     example = self.gateway.jvm.py4j.examples.ReturnerExample()
     returner = Returner(bad_type=True)
     self.assertRaises(
         Py4JJavaError, example.computeFloat,
         returner)
开发者ID:bartdag,项目名称:py4j,代码行数:7,代码来源:java_callback_test.py


示例3: perform_memory_tests

            def perform_memory_tests():
                python_gc()
                clientserver.jvm.py4j.instrumented.MetricRegistry.\
                    forceFinalization()
                sleep()

                createdSet = clientserver.jvm.py4j.instrumented.\
                    MetricRegistry.getCreatedObjectsKeySet()
                finalizedSet = clientserver.jvm.py4j.instrumented.\
                    MetricRegistry.getFinalizedObjectsKeySet()

                # 6 objects: ClientServer, JavaServer,
                # PythonClient, 3 ClientServerConnection.
                self.assertEqual(6, len(createdSet))

                # Should be 2: ClientServer, 1 ClientServerConnection
                # But for some reasons, Java refuses to collect the
                # clientserverconnection even though there are no strong
                # references.
                self.assertEqual(1, len(finalizedSet))

                # 8 objects: ClientServer, PythonServer, JavaClient,
                # GatewayProperty, PythonPing, 3 ClientServerConnection
                self.assertEqual(8, len(CREATED))

                # PythonPing + ClientServerConnection
                self.assertEqual(2, len(FINALIZED))
开发者ID:bartdag,项目名称:py4j,代码行数:27,代码来源:memory_leak_test.py


示例4: testProxyReturnerIntOverflow

 def testProxyReturnerIntOverflow(self):
     sleep()
     example = self.gateway.jvm.py4j.examples.ReturnerExample()
     returner = Returner(bad_type=True)
     self.assertRaises(
         Py4JJavaError, example.computeInt,
         returner)
开发者ID:bartdag,项目名称:py4j,代码行数:7,代码来源:java_callback_test.py


示例5: start_clientserver_example_app_process

def start_clientserver_example_app_process(
        start_java_client=False, start_short_timeout=False,
        start_gc_test=False, auth_token=None):
    args = ()
    gw_params = GatewayParameters()
    if auth_token:
        args = ("--auth-token", auth_token)
        gw_params = GatewayParameters(auth_token=auth_token)

    # XXX DO NOT FORGET TO KILL THE PROCESS IF THE TEST DOES NOT SUCCEED
    if start_short_timeout:
        p = Process(target=start_short_timeout_clientserver_example_server,
                    args=args)
    elif start_java_client:
        p = Process(target=start_java_clientserver_example_server, args=args)
    elif start_gc_test:
        p = Process(target=start_java_clientserver_gc_example_server,
                    args=args)
    else:
        p = Process(target=start_clientserver_example_server, args=args)
    p.start()
    sleep()

    check_connection(gateway_parameters=gw_params)
    return p
开发者ID:bartdag,项目名称:py4j,代码行数:25,代码来源:client_server_test.py


示例6: testJavaGC

    def testJavaGC(self):
        # This will only work with some JVM.
        with clientserver_example_app_process():
            client_server = ClientServer(
                JavaParameters(), PythonParameters())
            example = client_server.entry_point.getNewExample()
            impl = IHelloImpl()
            self.assertEqual("This is Hello!", example.callHello(impl))
            self.assertEqual(
                "This is Hello;\n10MyMy!\n;",
                example.callHello2(impl))
            self.assertEqual(2, len(client_server.gateway_property.pool))

            # Make sure that finalizers do not block by calling the Java
            # finalizer again
            impl2 = IHelloImpl()
            self.assertEqual("This is Hello!", example.callHello(impl2))
            self.assertEqual(3, len(client_server.gateway_property.pool))

            # The two PythonProxies should be evicted on the Java side
            # Java should tell python to release the references.
            client_server.jvm.java.lang.System.gc()

            # Leave time for sotimeout
            sleep(3)
            self.assertTrue(len(client_server.gateway_property.pool) < 2)
            client_server.shutdown()
开发者ID:dongjoon-hyun,项目名称:py4j,代码行数:27,代码来源:client_server_test.py


示例7: start_example_app_process2

def start_example_app_process2():
    # XXX DO NOT FORGET TO KILL THE PROCESS IF THE TEST DOES NOT SUCCEED
    p = Process(target=start_example_server2)
    p.start()
    sleep()
    check_connection()
    return p
开发者ID:DiamondLightSource,项目名称:py4j,代码行数:7,代码来源:java_callback_test.py


示例8: example_app_process

def example_app_process():
    p = start_example_app_process()
    try:
        yield p
    finally:
        p.join()
        sleep()
开发者ID:shobull,项目名称:hue,代码行数:7,代码来源:java_dir_test.py


示例9: setUp

        def setUp(self):
            key_file = os.path.join(
                os.path.dirname(os.path.realpath(__file__)),
                "selfsigned.pem")

            client_ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
            client_ssl_context.verify_mode = ssl.CERT_REQUIRED
            client_ssl_context.check_hostname = True
            client_ssl_context.load_verify_locations(cafile=key_file)

            server_ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
            server_ssl_context.load_cert_chain(key_file, password='password')

            callback_server_parameters = CallbackServerParameters(
                ssl_context=server_ssl_context)
            # address must match cert, because we're checking hostnames
            gateway_parameters = GatewayParameters(
                address='localhost',
                ssl_context=client_ssl_context)

            self.p = start_example_tls_process()
            self.gateway = JavaGateway(
                gateway_parameters=gateway_parameters,
                callback_server_parameters=callback_server_parameters)
            sleep()
开发者ID:dongjoon-hyun,项目名称:py4j,代码行数:25,代码来源:java_tls_test.py


示例10: testGC

    def testGC(self):
        with gateway_example_app_process("nomem"):
            # This will only work with some JVM.
            gateway = JavaGateway(
                callback_server_parameters=CallbackServerParameters())
            sleep()
            example = gateway.entry_point.getNewExample()
            impl = IHelloImpl()
            self.assertEqual("This is Hello!", example.callHello(impl))
            self.assertEqual(
                "This is Hello;\n10MyMy!\n;",
                example.callHello2(impl))
            self.assertEqual(2, len(gateway.gateway_property.pool))

            # Make sure that finalizers do not block
            impl2 = IHelloImpl()
            self.assertEqual("This is Hello!", example.callHello(impl2))
            self.assertEqual(3, len(gateway.gateway_property.pool))

            gateway.jvm.java.lang.System.gc()

            # Leave time for sotimeout
            sleep(3)
            # Make sure the three objects have not been removed from the pool
            # because the Java side should not send gc request.
            self.assertEqual(len(gateway.gateway_property.pool), 3)
            gateway.shutdown()
开发者ID:DiamondLightSource,项目名称:py4j,代码行数:27,代码来源:java_callback_test.py


示例11: testProxy

 def testProxy(self):
     #        self.gateway.jvm.py4j.GatewayServer.turnLoggingOn()
     sleep()
     example = self.gateway.entry_point.getNewExample()
     impl = IHelloImpl()
     self.assertEqual("This is Hello!", example.callHello(impl))
     self.assertEqual("This is Hello;\n10MyMy!\n;", example.callHello2(impl))
开发者ID:DawnScience,项目名称:py4j,代码行数:7,代码来源:java_callback_test.py


示例12: testGoodRetryFromJava

    def testGoodRetryFromJava(self):
        """Should retry from Java to Python.
        Similar use case as testGoodRetry, but from Java: Python calls Java,
        which calls Python back. Then Java waits for a while and calls Python
        again.

        Because Python Server has been waiting for too much time, the
        receiving socket has closed so the call from Java to Python will fail
        on send, and Java must retry by creating a new connection
        (ClientServerConnection).

        Because ClientServer reuses the same connection in each thread, we must
        launch a new thread on the Java side to correctly test the Python
        Server.
        """
        client_server = ClientServer(
            JavaParameters(), PythonParameters(read_timeout=0.250))
        with clientserver_example_app_process():
            try:
                operator = WaitOperator(0)
                opExample = client_server.jvm.py4j.examples.OperatorExample()
                opExample.launchOperator(operator, 500)
                sleep(0.1)
                str_connection = str(
                    list(client_server._callback_server.connections)[0])

                sleep(0.75)
                str_connection2 = str(
                    list(client_server._callback_server.connections)[0])
                self.assertNotEqual(str_connection, str_connection2)
            except Py4JJavaError:
                self.fail("Callbackserver did not retry.")
            finally:
                client_server.shutdown()
开发者ID:DiamondLightSource,项目名称:py4j,代码行数:34,代码来源:client_server_test.py


示例13: testBytes

 def testBytes(self):
     sleep()
     operator = CustomBytesOperator()
     returnbytes = self.gateway.entry_point.callBytesOperator(operator)
     self.assertEqual(2, returnbytes[0])
     self.assertEqual(6, returnbytes[-1])
     sleep()
开发者ID:DawnScience,项目名称:py4j,代码行数:7,代码来源:java_callback_test.py


示例14: internal_work

 def internal_work():
     gateway2 = InstrJavaGateway(gateway_parameters=GatewayParameters(
         port=DEFAULT_PORT+5))
     sleep()
     work_with_object(gateway2)
     python_gc()
     sleep()
     gateway2.shutdown()
开发者ID:bartdag,项目名称:py4j,代码行数:8,代码来源:memory_leak_test.py


示例15: testProxy

 def testProxy(self):
     sleep()
     example = self.gateway.entry_point.getNewExample()
     impl = IHelloImpl()
     self.assertEqual("This is Hello!", example.callHello(impl))
     self.assertEqual(
         "This is Hello;\n10MyMy!\n;",
         example.callHello2(impl))
开发者ID:18600597055,项目名称:hue,代码行数:8,代码来源:java_callback_test.py


示例16: testMethodConstructor

 def testMethodConstructor(self):
     sleep()
     goodAddition = GoodAddition()
     oe1 = self.gateway.jvm.py4j.examples.OperatorExample()
     # Test method
     oe1.randomBinaryOperator(goodAddition)
     # Test constructor
     oe2 = self.gateway.jvm.py4j.examples.OperatorExample(goodAddition)
     self.assertTrue(oe2 is not None)
开发者ID:DawnScience,项目名称:py4j,代码行数:9,代码来源:java_callback_test.py


示例17: testMethodConstructor

 def testMethodConstructor(self):
     sleep()
     adder = Adder()
     oe1 = self.gateway.jvm.py4j.examples.OperatorExample()
     # Test method
     oe1.randomBinaryOperator(adder)
     # Test constructor
     oe2 = self.gateway.jvm.py4j.examples.OperatorExample(adder)
     self.assertTrue(oe2 is not None)
开发者ID:dongjoon-hyun,项目名称:py4j,代码行数:9,代码来源:java_tls_test.py


示例18: start_gateway_server_example_app_process

def start_gateway_server_example_app_process(start_gateway_server=True):
    # XXX DO NOT FORGET TO KILL THE PROCESS IF THE TEST DOES NOT SUCCEED
    if start_gateway_server:
        p = Process(target=start_instrumented_gateway_server)
    else:
        p = Process(target=start_instrumented_clientserver)
    p.start()
    sleep()
    check_connection()
    return p
开发者ID:bartdag,项目名称:py4j,代码行数:10,代码来源:memory_leak_test.py


示例19: testPeriodicCleanup

 def testPeriodicCleanup(self):
     operator = FalseAddition()
     self.assertRaises(
         Exception, self.gateway.entry_point.randomTernaryOperator,
         operator)
     # Time for periodic cleanup
     sleep(2)
     self.assertRaises(
         Exception, self.gateway.entry_point.randomTernaryOperator,
         operator)
开发者ID:18600597055,项目名称:hue,代码行数:10,代码来源:java_callback_test.py


示例20: start_clientserver_example_app_process

def start_clientserver_example_app_process(start_java_client=False):
    # XXX DO NOT FORGET TO KILL THE PROCESS IF THE TEST DOES NOT SUCCEED
    if not start_java_client:
        p = Process(target=start_clientserver_example_server)
    else:
        p = Process(target=start_java_clientserver_example_server)
    p.start()
    sleep()
    test_gateway_connection()
    return p
开发者ID:dongjoon-hyun,项目名称:py4j,代码行数:10,代码来源:client_server_test.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python monitor.Monitor类代码示例发布时间:2022-05-27
下一篇:
Python pulp.LpProblem类代码示例发布时间: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