Package py4j

Class PythonClient

All Implemented Interfaces:
GatewayServerListener, Py4JPythonClient, Py4JPythonClientPerThread

public class PythonClient extends CallbackClient implements Py4JPythonClientPerThread, GatewayServerListener

Subclass of CallbackClient that implements the new threading model, ensuring that each thread uses its own connection.

  • Field Details

  • Constructor Details

    • PythonClient

      public PythonClient(Gateway gateway, List<Class<? extends Command>> customCommands, int pythonPort, InetAddress pythonAddress, long minConnectionTime, TimeUnit minConnectionTimeUnit, SocketFactory socketFactory, Py4JJavaServer javaServer)
      Parameters:
      gateway - The gateway used to pool Java instances created on the Python side.
      customCommands - Optional list of custom commands that can be invoked by the Python side.
      pythonPort - Port the PythonClient should connect to.
      pythonAddress - Address (IP) the PythonClient should connect to.
      minConnectionTime - Minimum time to wait before closing unused connections. Not used with PythonClient.
      minConnectionTimeUnit - Time unit of minConnectionTime
      socketFactory - SocketFactory used to create a socket.
      javaServer - The JavaServer used to receive commands from the Python side.
    • PythonClient

      public PythonClient(Gateway gateway, List<Class<? extends Command>> customCommands, int pythonPort, InetAddress pythonAddress, long minConnectionTime, TimeUnit minConnectionTimeUnit, SocketFactory socketFactory, Py4JJavaServer javaServer, boolean enableMemoryManagement, int readTimeout)
      Parameters:
      gateway - The gateway used to pool Java instances created on the Python side.
      customCommands - Optional list of custom commands that can be invoked by the Python side.
      pythonPort - Port the PythonClient should connect to.
      pythonAddress - Address (IP) the PythonClient should connect to.
      minConnectionTime - Minimum time to wait before closing unused connections. Not used with PythonClient.
      minConnectionTimeUnit - Time unit of minConnectionTime
      socketFactory - SocketFactory used to create a socket.
      javaServer - The JavaServer used to receive commands from the Python side.
      enableMemoryManagement - If false, the Java side does not tell the Python side when a Python proxy is garbage collected.
      readTimeout - Time in milliseconds (0 = infinite). Once connected to the Python side, if the Java side does not receive a response after this time, the connection with the Python program is closed. If readTimeout = 0, a default readTimeout of 1000 is used for operations that must absolutely be non-blocking.
    • PythonClient

      public PythonClient(Gateway gateway, List<Class<? extends Command>> customCommands, int pythonPort, InetAddress pythonAddress, long minConnectionTime, TimeUnit minConnectionTimeUnit, SocketFactory socketFactory, Py4JJavaServer javaServer, boolean enableMemoryManagement, int readTimeout, String authToken)
      Parameters:
      gateway - The gateway used to pool Java instances created on the Python side.
      customCommands - Optional list of custom commands that can be invoked by the Python side.
      pythonPort - Port the PythonClient should connect to.
      pythonAddress - Address (IP) the PythonClient should connect to.
      minConnectionTime - Minimum time to wait before closing unused connections. Not used with PythonClient.
      minConnectionTimeUnit - Time unit of minConnectionTime
      socketFactory - SocketFactory used to create a socket.
      javaServer - The JavaServer used to receive commands from the Python side.
      enableMemoryManagement - If false, the Java side does not tell the Python side when a Python proxy is garbage collected.
      readTimeout - Time in milliseconds (0 = infinite). Once connected to the Python side, if the Java side does not receive a response after this time, the connection with the Python program is closed. If readTimeout = 0, a default readTimeout of 1000 is used for operations that must absolutely be non-blocking.
      authToken - Token for authenticating with the callback server.
  • Method Details