本文整理汇总了Python中py4j.tests.java_gateway_test.sleep函数的典型用法代码示例。如果您正苦于以下问题:Python sleep函数的具体用法?Python sleep怎么用?Python sleep使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sleep函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
示例2: testProxyReturnerFloatErrorTypeConversion
def testProxyReturnerFloatErrorTypeConversion(self):
sleep()
example = self.gateway.jvm.py4j.examples.ReturnerExample()
returner = Returner(bad_type=True)
self.assertRaises(
Py4JJavaError, example.computeFloat,
returner)
示例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))
示例4: testProxyReturnerIntOverflow
def testProxyReturnerIntOverflow(self):
sleep()
example = self.gateway.jvm.py4j.examples.ReturnerExample()
returner = Returner(bad_type=True)
self.assertRaises(
Py4JJavaError, example.computeInt,
returner)
示例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
示例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()
示例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
示例8: example_app_process
def example_app_process():
p = start_example_app_process()
try:
yield p
finally:
p.join()
sleep()
示例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()
示例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()
示例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))
示例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()
示例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()
示例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()
示例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))