杀死py4j请求和与其关联的Java进程

时间:2019-07-16 07:19:10

标签: java python py4j

我正在使用py4j java网关从python调用Java函数。

python代码

from py4j.java_gateway import JavaGateway, GatewayParameters

  gateway=JavaGateway(gateway_parameters=GatewayParameters
  (port=port.port))

  promo_engine = gateway.entry_point

  order_json_string = promo_engine.placeOrder(1L, True, 1L, "true", 
  None, "1PAY", False, cart)

placeOrder函数是用Java代码编写的

将网关服务器放在 Java代码

GatewayServer gatewayServer1 = new GatewayServer(new 
   PromotionBO(),port);
   gatewayServer1.start();

public Order placeOrder() { 
//some logic
// this is the function which is called from python 
}

如果响应时间超过30秒,有什么办法可以关闭请求并杀死Java进程?

谢谢。

0 个答案:

没有答案