Class CPythonSpawner.CPythonProcess

java.lang.Object
nz.org.riskscape.cpython.CPythonSpawner.CPythonProcess
Enclosing class:
CPythonSpawner

public class CPythonSpawner.CPythonProcess extends Object

Simple class to help track child CPython processes that we spawn.

  • Constructor Details

    • CPythonProcess

      public CPythonProcess(Process proc, nz.org.riskscape.engine.resource.Resource script)
  • Method Details

    • getErrorText

      public String getErrorText()
      Returns:
      any stderr output produced by this process without buffering - returns what is available at the time without blocking (at least not on purpose)
    • hasErrorText

      public boolean hasErrorText()
    • exittedOK

      public boolean exittedOK()

      Simple test for checking the process finished successfully. Don't call it unless you expect (and want) the process to have exitted, or you'll end up inadvertantly killing it by calling this function - it will forcibly destroy the process if it hasn't already exitted.

      Returns:
      true if the process exitted ok, waiting up to a minute for this to happen before killing it forcibly and returning false.
    • destroy

      public void destroy()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • isAlive

      public boolean isAlive()
    • wasDestroyed

      public boolean wasDestroyed()
      Returns:
      true if this process was destroyed by us (by calling destroy)
    • getChild

      public Process getChild()
    • getUserScript

      public nz.org.riskscape.engine.resource.Resource getUserScript()
    • getChildStdIn

      public DataOutputStream getChildStdIn()

      Writing to this stream will send data to the child process's stdin

    • getChildStdOut

      public DataInputStream getChildStdOut()

      Reading from this stream will receive data from the child process's stdout