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


Python JavaGateway.get_callback_server方法代码示例

本文整理汇总了Python中py4j.java_gateway.JavaGateway.get_callback_server方法的典型用法代码示例。如果您正苦于以下问题:Python JavaGateway.get_callback_server方法的具体用法?Python JavaGateway.get_callback_server怎么用?Python JavaGateway.get_callback_server使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在py4j.java_gateway.JavaGateway的用法示例。


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

示例1: test_all_regular_signals_auto_start

# 需要导入模块: from py4j.java_gateway import JavaGateway [as 别名]
# 或者: from py4j.java_gateway.JavaGateway import get_callback_server [as 别名]
 def test_all_regular_signals_auto_start(self):
     listener = MockListener(self)
     with gateway_example_app_process(None):
         server_started.connect(listener.started)
         gateway = JavaGateway(
             gateway_parameters=GatewayParameters(),
             callback_server_parameters=CallbackServerParameters())
         server_stopped.connect(
             listener.stopped, sender=gateway.get_callback_server())
         server_connection_started.connect(
             listener.connection_started,
             sender=gateway.get_callback_server())
         server_connection_stopped.connect(
             listener.connection_stopped,
             sender=gateway.get_callback_server())
         pre_server_shutdown.connect(
             listener.pre_shutdown, sender=gateway.get_callback_server())
         post_server_shutdown.connect(
             listener.post_shutdown, sender=gateway.get_callback_server())
         example = gateway.entry_point.getNewExample()
         impl = IHelloImpl()
         self.assertEqual("This is Hello!", example.callHello(impl))
         gateway.shutdown()
     self.assertEqual(1, listener.received["started"])
     self.assertEqual(1, listener.received["stopped"])
     self.assertEqual(1, listener.received["pre_shutdown"])
     self.assertEqual(1, listener.received["post_shutdown"])
     self.assertEqual(1, listener.received["connection_started"])
     self.assertEqual(1, listener.received["connection_stopped"])
开发者ID:DiamondLightSource,项目名称:py4j,代码行数:31,代码来源:py4j_signals_test.py

示例2: ResetCallbackClientTest

# 需要导入模块: from py4j.java_gateway import JavaGateway [as 别名]
# 或者: from py4j.java_gateway.JavaGateway import get_callback_server [as 别名]
class ResetCallbackClientTest(unittest.TestCase):
    def setUp(self):
        self.p = start_example_app_process()
        self.gateway = JavaGateway(
            callback_server_parameters=CallbackServerParameters(port=0))
        sleep()

    def tearDown(self):
        safe_shutdown(self)
        self.p.join()
        sleep()

    def testProxy(self):
        sleep()
        pythonAddress = self.gateway.java_gateway_server.getPythonAddress()
        port = self.gateway.get_callback_server().get_listening_port()
        self.gateway.java_gateway_server.resetCallbackClient(
            pythonAddress, port)

        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:DiamondLightSource,项目名称:py4j,代码行数:27,代码来源:java_callback_test.py

示例3: get_gateway

# 需要导入模块: from py4j.java_gateway import JavaGateway [as 别名]
# 或者: from py4j.java_gateway.JavaGateway import get_callback_server [as 别名]
def get_gateway(extra_jar=None):

    if extra_jar is None:
        extra_jar = find_jar_path()

    port = launch_gateway(
        die_on_exit=True, classpath=extra_jar,
        # redirect_stderr=sys.stderr, redirect_stdout=sys.stdout
    )

    gateway = JavaGateway(gateway_parameters=GatewayParameters(port=port),
                          callback_server_parameters=CallbackServerParameters(port=0))

    # retrieve the port on which the python callback server was bound to.
    python_port = gateway.get_callback_server().get_listening_port()

    gateway.java_gateway_server.resetCallbackClient(
        gateway.java_gateway_server.getCallbackClient().getAddress(),
        python_port)

    return gateway
开发者ID:nqbao,项目名称:python-orc,代码行数:23,代码来源:gateway.py

示例4: connectToJava

# 需要导入模块: from py4j.java_gateway import JavaGateway [as 别名]
# 或者: from py4j.java_gateway.JavaGateway import get_callback_server [as 别名]
def connectToJava(port):
    if not isPy4J:
        sys.stderr.write("Please install py4j to run scripts in native Python.\n")
    port = int(port)
    if port > 0:
        # connect python side to Java side with Java dynamic port and start python
        # callback server with a dynamic port
        gateway = JavaGateway(
                          gateway_parameters=GatewayParameters(port=port),
                          callback_server_parameters=CallbackServerParameters(port=0))

        # retrieve the port to which the python callback server was bound
        python_port = gateway.get_callback_server().get_listening_port()

        # tell the Java side to connect to the python callback server with the new
        # python port, using the java_gateway_server attribute that retrieves the
        # GatewayServer instance
        addr = gateway.java_gateway_server.getCallbackClient().getAddress()
        gateway.java_gateway_server.resetCallbackClient(addr, python_port)
    else:
        return None
        #raise connect2jException
    return gateway
开发者ID:kasemir,项目名称:org.csstudio.display.builder,代码行数:25,代码来源:connect2j.py

示例5: launch_gateway

# 需要导入模块: from py4j.java_gateway import JavaGateway [as 别名]
# 或者: from py4j.java_gateway.JavaGateway import get_callback_server [as 别名]
logging.basicConfig(level=logging.INFO, format="%(message)s")


# Launch a gateway to the all Java JAR dependencies that we have
classpath = ':'.join([
    os.path.join(settings.DEPS_DIR, jar)
    for jar in os.listdir('deps')
])
port_number = launch_gateway(
    classpath=classpath,
    die_on_exit=True,
)
gateway = JavaGateway(
    gateway_parameters=GatewayParameters(port=port_number),
    callback_server_parameters=CallbackServerParameters(port=0),
)
python_port = gateway.get_callback_server().get_listening_port()
gateway.java_gateway_server.resetCallbackClient(
    gateway.java_gateway_server.getCallbackClient().getAddress(),
    python_port,
)


def java_isinstance(java_object, java_class):
    '''
    Convenience method to abstract away the gateway server to the
    Py4J `is_instance_of` method, which is documented here:
    https://www.py4j.org/py4j_java_gateway.html#javaobject
    '''
    return is_instance_of(gateway, java_object, java_class)
开发者ID:andrewhead,项目名称:tutorons-server,代码行数:32,代码来源:gateway.py


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